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 j = 0; j < n; j++){
		string s; cin >> s;
		char c;
		int num = 0;
		for (int i = 0; i != s.size(); i++){
			if (i == 0 || s[i - 1] == '0') {
				if (s[i] == '0')goto cont;
				else {
					c = s[i]; 
					num++;
				}
			}
			else{
				if (s[i] == '0') {
					if (c == '1') {
						num = num % 5;
						if (num == 1)cout << '.';
						else if (num == 2)cout << ',';
						else if (num == 3)cout << '!';
						else if (num == 4)cout << '?';
						else cout << ' ';
					}
					else if (c == '2') {
						num = num % 3;
						if (num == 1)cout << 'a';
						else if (num == 2)cout << 'b';
						else cout << 'c';
					}
					else if (c == '3') {
						num = num % 3;
						if (num == 1)cout << 'd';
						else if (num == 2)cout << 'e';
						else cout << 'f';
					}
					else if (c == '4') {
						num = num % 3;
						if (num == 1)cout << 'g';
						else if (num == 2)cout << 'h';
						else cout << 'i';
					}
					else if (c == '5') {
						num = num % 3;
						if (num == 1)cout << 'j';
						else if (num == 2)cout << 'k';
						else cout << 'l';
					}
					else if (c == '6') {
						num = num % 3;
						if (num == 1)cout << 'm';
						else if (num == 2)cout << 'n';
						else cout << 'o';
					}
					else if (c == '7') {
						num = num % 4;
						if (num == 1)cout << 'p';
						else if (num == 2)cout << 'q';
						else if (num == 3)cout << 'r';
						else cout << 's';
					}
					else if (c == '8') {
						num = num % 3;
						if (num == 1)cout << 't';
						else if (num == 2)cout << 'u';
						else cout << 'v';
					}
					else if (c == '9') {
						num = num % 4;
						if (num == 1)cout << 'w';
						else if (num == 2)cout << 'x';
						else if (num == 3)cout << 'y';
						else cout << 'z';
					}
					num = 0;
				}
				else num++;
			}
		cont:;
		}
		cout << endl;
	}
}

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

const string M[] = {"",
                    ".,!? ",
                    "abc",
                    "def",
                    "ghi",
                    "jkl",
                    "mno",
                    "pqrs",
                    "tuv",
                    "wxyz"};
  
int main() {
  int T;
  cin >> T;
  cin.ignore();
  while(T--) {
    string s;
    getline(cin, s);
    for(int i = 0, j = -1, k = -1; i < s.size(); ++i) {
      int d = s[i] - '0';
      if(d == 0) {
        if(j != -1) {
          cout << M[j][k];
          j = k = -1;
        }
      } else {
        j = d;
        k = (k + 1) % M[j].size();
      }
    }
    cout << endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <utility>
#include <vector>
#include <string>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
bool scan(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

int main() {
	vector<string> b = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	string s;
	for (int i = in(); i--;) {
		scan(s);
		int n = -1, p = -1;
		for (char c: s) {
			c -= '0';
			if (c == n)
				p++;
			else {
				if (!c && n != -1)
					out(b[n][(p) % (int) b[n].size()]);
				n = c, p = 0;
			}
		}
		out('\n');
	}
}

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

char bt[9][8] = {
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};

int main(){
    int N;
    for(scanf("%d", &N); N--;){
        char mes[128];
        scanf(" %s", mes);
        int len = strlen(mes);
        int prv = 0, count = 0;
        for(int i = 0; i < len; i++){
            if(mes[i] == '0'){
                if(prv > 0){
                    --prv;
                    printf("%c", bt[prv][--count % strlen(bt[prv])]);
                }
                count = 0;
            }else{
                count++;
            }
            prv = mes[i] - '0';
        }
        if(prv > 0){
            --prv;
            printf("%c", bt[prv][--count % strlen(bt[prv])]);
        }
        puts("");
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define repb(i,n) for(int i = (int)n;i >= 0;i--)
#define reps(i,m,n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i,m,n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v,n) sort(v,v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
#define ll long long int
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1;} return 0;}
using namespace std;
string s[] = {".,!? ", "abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    rep(i,n){
        string tmp,ans="";
        int cnt=0,al=0;
        cin >> tmp;
        rep(j,tmp.size()){
            if (j>0&&tmp[j]!='0'&&tmp[j] == tmp[j - 1])
            {
                cnt++;
                //cout << "cnt" << cnt << endl;
                if (tmp[j] == '1')
                {
                    cnt %= 5;
                }
                else if (( tmp[j] == '7' ||tmp[j] == '9') )
                {
                    cnt %= 4;
                }
                else{
                    cnt %= 3;
                }
            }
            if(j>0&&tmp[j-1]!='0'&&tmp[j]=='0'){
                //cout << j - 1 << endl;
                ans += s[tmp[j - 1] - '0' - 1][cnt];
                cnt = 0;
            }
            
        }
        cout << ans<<endl;

    }
    return 0;
}