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>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    char ans[][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'}
    };
    ll n; cin >> n;
    rep(i,n){
        string s(100000,0);
        cin >> s;
        int temp = 0;
        int counter =-1 ;
        for(int k = 0;k<(int)s.size();k++){
            int now = int(s[k]-48);
            if(k == 0){temp = now;counter++;}
            else if(now != 0){
                temp = now;counter++;}
            if(now == 0){
                if(temp  == 9 || temp == 7)
                    counter= counter%4;
                else if(temp != 1&& temp != 7 && temp!= 9)
                    counter=counter%3;
                else if(temp == 1)
                    counter =counter%5;
                cout << ans[temp][counter];
                temp = 0;counter =-1;;
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int T;
    cin >> T;
    string in;
    while(T--){
        cin >> in;
        int i = 0;
        int n = in.length();
        
        while(i<n){
            int s = i;
            while(i<n && in[i]!='0'){
                i++;
            }
            if(0<i && in[i-1]-'0'!=0){
                string st = table[in[i-1]-'0'];
                cout << st[(i-s-1)%st.length()];
            }
            i++;
        }
        cout << endl;
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    char c;
    char alpha[10]={'.','.','a','d','g','j','m','p','t','w'};
    char alpha1[5]={' ','.',',','!','?'};
    cin>>N;
    getchar();
    while(N--){
        int cnt=0,before,now=0;
        while(c=getchar(),c!='\n'){
            before = now;
            now = c-'0';
            if(now!=0)cnt++;
            else if(before==1){
                printf("%c",alpha1[cnt%5]);
                cnt=0;
            }else if(before!=0){
                printf("%c",alpha[before]+(cnt-1)%(before==7||before==9 ? 4 : 3));
                cnt=0;
            }
        }
        cout<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int main(){
	int n,temp,sum,box[]={1,5,3,3,3,3,3,4,3,4};
	char s[1030];
	char tab[10][5]={" ",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	cin>>n;
	while(n--){
		cin>>s;
		sum=0;
		for(int i=0;i<(int)strlen(s);i++){
			if(s[i]=='0'){
				if(sum!=0){
					cout<<tab[temp][(sum-1)%box[temp]];
				}
				sum=0;
			}
			else{
				temp=s[i]-'0';
				sum++;
			}
		}
		cout<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	int n;
	cin>>n;
    string a,b;
    for(int j=0;j<n;j++){
    	cin>>a;
        if(a=="0") break;
        int la=a.size();
        int c=0;
        for(int i=0;i<la;i++){
            if(a[i]=='0'){
                if(b=="1"){
                    c=c%5;
                    if(c==1) cout<<".";
                    if(c==2) cout<<",";
                    if(c==3) cout<<"!";
                    if(c==4) cout<<"?";
                    if(c==0) cout<<" "; 
                }
                if(b=="2"){
                    c=c%3;
                    if(c==1) cout<<"a";
                    if(c==2) cout<<"b";
                    if(c==0) cout<<"c";
                }
                if(b=="3"){
                    c=c%3;
                    if(c==1) cout<<"d";
                    if(c==2) cout<<"e";
                    if(c==0) cout<<"f";
                }
                if(b=="4"){
                    c=c%3;
                    if(c==1) cout<<"g";
                    if(c==2) cout<<"h";
                    if(c==0) cout<<"i";
                }
                if(b=="5"){
                    c=c%3;
                    if(c==1) cout<<"j";
                    if(c==2) cout<<"k";
                    if(c==0) cout<<"l";
                }
                if(b=="6"){
                    c=c%3;
                    if(c==1) cout<<"m";
                    if(c==2) cout<<"n";
                    if(c==0) cout<<"o";
                }
                if(b=="7"){
                    c=c%4;
                    if(c==1) cout<<"p";
                    if(c==2) cout<<"q";
                    if(c==3) cout<<"r";
                    if(c==0) cout<<"s";
                }
                if(b=="8"){
                    c=c%3;
                    if(c==1) cout<<"t";
                    if(c==2) cout<<"u";
                    if(c==0) cout<<"v";
                }
                if(b=="9"){
                    c=c%4;
                    if(c==1) cout<<"w";
                    if(c==2) cout<<"x";
                    if(c==3) cout<<"y";
                    if(c==0) cout<<"z";
                }
                c=0;
                b="0";
            }
            else{
                b=a[i];
                c++;
            }
        }
        cout<<endl;
    }
    return 0;
}