Go: package main

import (
	"bytes"
	"fmt"
)

//Ktai has a keyboard and a state.
type Ktai struct {
	keyboard KeyBoard
	textBuf  *bytes.Buffer
}

// KeyBoard is type of a map.
type KeyBoard map[rune]string

// KEYBOARD that Ktai has
var KEYBOARD = KeyBoard{
	'0': "",
	'1': ".,!? ",
	'2': "abc",
	'3': "def",
	'4': "ghi",
	'5': "jkl",
	'6': "mno",
	'7': "pqrs",
	'8': "tuv",
	'9': "wxyz",
}

func main() {
	var N int
	fmt.Scanf("%d", &N)
	ktai := &Ktai{
		KEYBOARD, &bytes.Buffer{},
	}
	for i := 0; i < N; i++ {
		var numstr string
		fmt.Scanf("%s", &numstr)
		ktai.feed(numstr)
		ktai.print()
	}
}

func (ktai *Ktai) feed(str string) {
	var char *byte
	for _, v := range str {
		if v == '0' {
			if char != nil {
				ktai.textBuf.WriteByte(*char)
				char = nil
			}
			continue
		} else {
			runestring := ktai.keyboard[v]
			idx := ktai.indexOf(char, runestring)
			next := (idx + 1) % len(runestring)
			c := runestring[next]
			char = &c
		}
	}
}

func (ktai *Ktai) indexOf(ch *byte, str string) int {
	if ch == nil {
		return -1
	}
	r := rune(*ch)
	idx := -1
	for i, v := range str {
		if r == v {
			idx = i
			break
		}
	}
	return idx
}

func (ktai *Ktai) print() {
	fmt.Println(ktai.textBuf.String())
	ktai.textBuf.Reset()
}

C++: #include <iostream>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define SZ(x) (int)((x).size())

string table[] = {
    "",
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};

void solve(string s) {
    int n = s.size();
    int i=0;
    while(i < n) {
        int st = i;
        while(i<n and s[i]!='0') i++;
        if(0<i and s[i-1]-'0' != 0) {
            string t = table[s[i-1]-'0'];
            cout << t[(i - st - 1) % SZ(t)];
        }
        i++;
    }
    cout << "\n";
}

int main() {
    int n; cin>>n;
    rep(data,n) {
        string s; cin >> s;
        solve(s);
    }
    return 0;
}

C++: //#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 600000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000 大きいとワ―シャルフロイドでオーバーフローを起こす
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0,0 };



int main(void) {

	string s;
	int n;
	cin >> n;
	int count[10] = {};
	int now = -1;
	char c;
	
	FOR(k, 1, n) {
		FOR(j, 0, 9) {
			count[j] = 0;
		}
		now = -1;

		cin >> s;

		FOR(i, 0, s.size() - 1) {
			if (s[i] == '0') {
				count[now]--;
				switch (now) {
				case 1:
					switch (count[now] % 5) {
					case 0:
						cout << ".";
						break;
					case 1:
						cout << ",";
						break;
					case 2:
						cout << "!";
						break;
					case 3:
						cout << "?";
						break;
					case 4:
						cout << " ";
						break;
					}
					break;
				case 2:
				case 3:
				case 4:
				case 5:
				case 6:
					c = 'a' + 3 * (now - 2) + (count[now] % 3);
					cout << c;
					break;
				case 7:
					c = 'p' + (count[now] % 4);
					cout << c;
					break;
				case 8:
					c = 't' + (count[now] % 3);
					cout << c;
					break;
				case 9:
					c = 'w' + (count[now] % 4);
					cout << c;
					break;
				}

				FOR(j, 0, 9) {
					count[j] = 0;
				}
				now = 0;
			}
			else {
				count[s[i] - '0']++;
				now = s[i] - '0';
			}

		}
		cout << endl;
	}

	
	

	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


void solve(){
    string s;
    cin>>s;
    string ans="";
    int cnt=0;
    vector<vector<char> > v(10);
    v[1]={'.',',','!','?',' '};
    v[2]={'a','b','c'};
    v[3]={'d','e','f'};
    v[4]={'g','h','i'};
    v[5]={'j','k','l'};
    v[6]={'m','n','o'};
    v[7]={'p','q','r','s'};
    v[8]={'t','u','v'};
    v[9]={'w','x','y','z'};
    rep(i,s.size()){
        if(s[i]!='0')++cnt;
        else {
            if(cnt==0)continue;
            ans+=v[s[i-1]-'0'][(cnt-1)%v[s[i-1]-'0'].size()];
            cnt=0;
        }
    }
    cout<<ans<<endl;
}
int main(){
    int n;
    cin>>n;
    rep(i,n)solve();
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007
 
#define ARRAY_MAX 100005
 
int main(){

    string s[10] = {{""},
                    {'.',',','!','?',' '},
                    {'a','b','c'},
                    {'d','e','f'},
                    {'g','h','i'},
                    {'j','k','l'},
                    {'m','n','o'},
                    {'p','q','r','s'},
                    {'t','u','v'},
                    {'w','x','y','z'}};

    int n;
    cin >> n;
    REP(i,n){
        string ans;
        string str;
        cin >> str;
        int cnt = 0;
        REP(j,str.length()){
            if(str[j] != '0'){
                cnt++;
            }else{
                if(j != 0 && str[j-1] != '0'){
                    int index = str[j-1]-'0';//index
                    if(index == 1){
                        ans.push_back(s[index][(cnt-1)%5]);
                    }else if(index == 7 || index == 9){
                        ans.push_back(s[index][(cnt-1)%4]);
                    }else{
                        ans.push_back(s[index][(cnt-1)%3]);
                    }
                    cnt = 0;
                }else{
                    cnt = 0;
                }
            }
        }
        cout << ans << endl;
    }




    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  char m[9][5]={{'.',',','!','?',' '},
		{'a','b','c','1','1'},
		{'d','e','f','1','1'},
		{'g','h','i','1','1'},
		{'j','k','l','1','1'},
		{'m','n','o','1','1'},
		{'p','q','r','s','1'},
		{'t','u','v','1','1'},
		{'w','x','y','z','1'}};

  int a,count=0,c[100],d;
  char b[10000][1024];
  cin>>a;
  for(int i=0;i<a;i++){
    scanf("%s",b[i]);
    c[i]=strlen(b[i]);
    for(int j=0;j<c[i];j++){
      if(b[i][j]!='0')count++;
      else
	if(b[i][j-1]!=0){
	  d=(int)(b[i][j-1])-48;

	  if(d==1)
	    if(count%5!=0)
	      cout<<m[d-1][count%5-1];
	    else cout<<m[d-1][4];

	  else if(d==7 || d==9)
	    if(count%4!=0)
	      cout<<m[d-1][count%4-1];
	    else cout<<m[d-1][3];

	  else
	    if(count%3!=0)
	      cout<<m[d-1][count%3-1];
	    else cout<<m[d-1][2]; 
	  count=0;
	}
    }
    cout<<endl;
  }
  return 0;
}