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++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

void reader(int &a) { scanf("%d", &a); }
void reader(double &a) { scanf("%lf", &a); }
void reader(char a[]) { scanf("%s", a); }
void reader(char &a) { scanf(" %c", &a); }
void reader(ll &a) { scanf("%lld", &a); }
void reader(ull &a) { scanf("%llu", &a); }
// void reader(string& a){cin >> a;};
template<class T, class U> void reader(T& t, U& u) { reader(t); reader(u); }
template<class T, class U, class V> void reader(T& t, U& u, V& v) { reader(t); reader(u); reader(v); }

void writer(const int a, char c) { printf("%d", a); putchar(c); }
void writer(const ll a, char c) { printf("%lld", a); putchar(c); }
void writer(const ull a, char c) { printf("%llu", a); putchar(c); }
void writer(const double a, char c) { printf("%.20lf", a); putchar(c); }
void writer(const char a[]) { printf("%s", a); };
void writer(const char a[], char c) { printf("%s", a); putchar(c); };
void writer(const char a, char c) { putchar(a); putchar(c); };
template<class T> void writerLn(T t) { writer(t, '\n'); }
template<class T, class U> void writerLn(T t, U u) { writer(t, ' '); writer(u, '\n'); }
template<class T, class U, class V> void writerLn(T t, U u, V v) { writer(t, ' '); writer(u, ' '); writer(v, '\n'); }
template<class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }
template<class T> void writerVec(vector<T> x) { int n = x.size(); int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }

vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); }return v; }
// #define int ll
bool test = 1;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define MAX 300000
//.....................
ull mod = (int)1e9 + 7;

signed main(void)
{
	string s[10];
	s[1] = ".,!? ";
	s[2] = "abc";
	s[3] = "def";
	s[4] = "ghi";
	s[5] = "jkl";
	s[6] = "mno";
	s[7] = "pqrs";
	s[8] = "tuv";
	s[9] = "wxyz";
	int t;
	cin >> t;
	rep(i, t) {
		string res;
		string message;
		cin >> message;
		char now;
		rep(i, message.size()) {
			now = message[i];
			if (now == '0') continue;
			int cnt = 0;
			REP(j, i + 1, message.size()) {
				if (message[j] != now) {
					cnt = j - i;
					break;
				}
			}
			i += cnt;
			res += s[now - '0'][(cnt - 1) % s[now - '0'].size()];
		}
		cout << res << endl;
	}
	return 0;
}

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

int main(){
  int n;
  int len;
  int count;
  int i,j;
  int num;
  int flg;
  char moji[10][6]={
    {' ',' ',' ',' ',' '},
    {'.',',','!','?',' '},
    {'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'}
  };

  cin >> n;

  for(i = 0 ; i < n ; i++){
    num = 0;
    count = -1;
    string str;

    cin >> str;

    for(j = 0 ; j < str.size() ; j++){
      flg = 1;
      if(str[j]=='1'){
	num = 1; 
      }else if(str[j]=='2'){
	num = 2; 
      }else if(str[j]=='3'){
	num = 3; 
      }else if(str[j]=='4'){
	num = 4;
      } else if(str[j]=='5'){
	num = 5; 
      }else if(str[j]=='6'){
	num = 6; 
      } else if(str[j]=='7'){
	num = 7;
      }else if(str[j]=='8'){
	num = 8; 
      }else if(str[j]=='9'){
	num = 9; 
      }else{
	if(num == 0){
	  continue;
	}

	if(num == 1){
	  count = count % 5;
	}else if(num == 7 || num == 9){
	  count = count % 4;
	}else{
	  count = count % 3;
	}

	cout << moji[num][count];

	flg = 0;
	count = -1;
	num = 0;
      }
      if(flg == 1) count++;
    }
    cout << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	const string TABLE[] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	int n;
	cin >> n;
	for(int i=0;i<n;++i){
		string s;
		string ans;
		int k=0,l=-1;
		bool in = false;
		cin >> s;
		for(int j=0;j<s.size();++j){
			if(s[j]=='0'){
				if(in){
					ans+=TABLE[k][l];
				}
				in = false;
				k=0;
				l=-1;
			}else{
				in = true;
				l++;
				k=s[j]-'1';
				l%=TABLE[k].size();
			}
		}
		cout << ans << "\n";
	}
	return 0;
}

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

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

string solve(string in){
  string res="";
  int c=0;
  int n_in=0;
  for(int i=0;i<in.size();i++){
    int t_in=in[i]-'0';
    if(t_in==0){
      if(n_in!=0){
        res+=push[n_in][(c%push[n_in].size())];
      }
      n_in=0;
      c=0;
    }else{
      if(t_in==n_in){
        c++;
      }else{
        c=0;
	n_in=t_in;
      }
    }
  }
  return res;
}



int main(){
  string in;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>in;
    string ans=solve(in);
    if(ans.size()!=0){
      cout<<ans<<endl;
    }
  }
}

C++: #include<stdio.h>
#include<string.h>
int main()
{
	int n,a[]={0,5,3,3,3,3,3,4,3,4};
	char*p,*q,s[1028],*t[]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	scanf("%d",&n);
	while(n--)
	{
		memset(s,0,1028);
		scanf("%s",s);
		for(p=s;*p;)
		{
			q=strpbrk(p,"0\0");
			if(*p-'0')putchar(t[*p-'0'][(q-p-1)%a[*p-'0']]);
			p=q+1;
		}
		puts("");
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;

int main(){
    vector<string> k = {
        "",
        ".,!? ",
        "abc",
        "def",
        "ghi",
        "jkl",
        "mno",
        "pqrs",
        "tuv",
        "wxyz"
    };
    int n;
    cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        string ans = "";
        int ct = 0, now = 0;
        rep(j, s.size()){
            int x = s[j]-'0';
            if(x == 0){
                if(now == 0) continue;
                ans += k[now][ct%k[now].size()];
                now = 0;
            }else{
                if(now == x){
                    ct++;
                }else{
                    now = x;
                    ct = 0;
                }
            }
        }
        cout << ans << endl;
    }
            
}