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>
#include<string>

using namespace std;

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string input;
		int count=1;
		
		cin>>input;
		char first=input[0];
		for(int j=1;j<input.size();j++){
			if(first==input[j])count++;
			if(input[j]=='0'){
				if(input[j+1]=='0')continue;
				switch(first){
					case '1':
						switch(count%5){
							case 1:cout<<".";break;
							case 2:cout<<",";break;
							case 3:cout<<"!";break;
							case 4:cout<<"?";break;
							case 0:cout<<" ";break;
						}break;
					case '2':
						switch(count%3){
							case 1:cout<<"a";break;
							case 2:cout<<"b";break;
							case 0:cout<<"c";break;
						}break;
					case '3':
						switch(count%3){
							case 1:cout<<"d";break;
							case 2:cout<<"e";break;
							case 0:cout<<"f";break;
						}break;
					case '4':
						switch(count%3){
							case 1:cout<<"g";break;
							case 2:cout<<"h";break;
							case 0:cout<<"i";break;
						}break;
					case '5':
						switch(count%3){
							case 1:cout<<"j";break;
							case 2:cout<<"k";break;
							case 0:cout<<"l";break;
						}break;
					case '6':
						switch(count%3){
							case 1:cout<<"m";break;
							case 2:cout<<"n";break;
							case 0:cout<<"o";break;
						}break;
					case '7':
						switch(count%4){
							case 1:cout<<"p";break;
							case 2:cout<<"q";break;
							case 3:cout<<"r";break;
							case 0:cout<<"s";break;
						}break;
					case '8':
						switch(count%3){
							case 1:cout<<"t";break;
							case 2:cout<<"u";break;
							case 0:cout<<"v";break;
						}break;
					case '9':
						switch(count%4){
							case 1:cout<<"w";break;
							case 2:cout<<"x";break;
							case 3:cout<<"y";break;
							case 0:cout<<"z";break;
						}break;
				}
				first=input[j+1];
				count=0;
			}	
		}
		
			cout<<endl;	
	}
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	pair<int, string> deta[10];//int mod string ?????????
	deta[1] = mp(5, ".,!? ");
	deta[2] = mp(3, "abc");
	deta[3] = mp(3, "def");
	deta[4] = mp(3, "ghi");
	deta[5] = mp(3, "jkl");
	deta[6] = mp(3, "mno");
	deta[7] = mp(4, "pqrs");
	deta[8] = mp(3, "tuv");
	deta[9] = mp(4, "wxyz");
	//deta[0] = mp(0, "");

	int n; cin >> n;
	int tmp;
	rep(i, n){
		string tmp;
		cin >> tmp;
		int size = tmp.size();
		int cnt = 0;
		rep(j, size){
			//printf("j %d\n", j);
			if(tmp[j] == '0') continue;//?????????????????????????????????
	
			if(tmp[j] == tmp[j + 1]){
				cnt++;
				//printf("cnt++%d\n", cnt);
				continue;
			}
			else{
				int num = tmp[j] - '0';
				//printf("num%d\n", num);
				string moziretu = deta[num].se;
				//cout << moziretu <<endl;
				printf("%c", moziretu[cnt % deta[num].fi]);
				cnt = 0;
			}
		}
		printf("\n");
	}
	return 0;
}

C++: #include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

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

int main(int argc, char const *argv[]) {
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    vector<string>ans;
    for(int i=0;i<n;i++){
        cin >> s;
        ans.push_back(solve(s));
    }
    for(int i=0;i<n;i++){
        cout << ans[i]<<endl;
    }
}