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, p = 0, cnt;
	string key[] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	string str;
	
	cin;
	while (cin >> str) {
		for (char& c : str) {
			n = c - '0';
			if (n) {
				cnt++;
			} else if (p == n) {
			}else {
				cout << key[p][(cnt-1) % key[p].size()];
				cnt = 0;
			}
			p = n;
		}
		cout << endl;
	}
	
	return 0;
}

C++: #include <stdio.h>

int main(void) {
	const char list[10][5] = {
		{0,0,0,0,0},
		{'.',',','!','?', ' '},
		{'a','b','c',0,0},
		{'d','e','f',0,0},
		{'g','h','i',0,0},
		{'j','k','l',0,0},
		{'m','n','o',0,0},
		{'p','q','r','s',0},
		{'t','u','v',0,0},
		{'w','x','y','z',0},
	};
	char b,b2;
	int listc[10]= {5,5,3,3,3,3,3,4,3,4}, n,i;
	scanf("%d%*c", &n);
	for(i = 0; n>i; i++){
		while(1){
		int c = 0;
		b2 = '0';
		b = -1;
		while(scanf("%c", &b) != EOF){
			if(b == '0' || b == '\n') break;
			b2 = b;
			c++;
		}
		if(b == '\n' || b == -1) {
			printf("\n");
			break;
		}
		printf("%c", list[b2-'0'][(c-1)%listc[b2-'0']]);
		}
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <queue>
using namespace std;

void p(int nu, int key){
//cout<<"dckjw"<<nu<<" "<<key<<endl;
string s[10]={"",".,!?","cab","fde","igh","ljk","omn","spqr","vtu","zwxy"};
if(key==1){
nu=nu%5;
if(nu==0) cout<<" ";
else cout<<s[1][nu-1];
}
if(key==2){
nu=nu%3;
//cout<<s[2];
cout<<s[2][nu];
}
if(key==3){
nu=nu%3;
cout<<s[3][nu];
}
if(key==4){
nu=nu%3;
cout<<s[4][nu];
}
if(key==5){
nu=nu%3;
cout<<s[5][nu];
}
if(key==6){
nu=nu%3;
cout<<s[6][nu];
}
if(key==7){
nu=nu%4;
cout<<s[7][nu];
}
if(key==8){
nu=nu%3;
cout<<s[8][nu];
}
if(key==9){
//cout<<"9ban "<<nu<<endl;
nu=nu%4;
cout<<s[9][nu];
}


}
int main(){
string s;
int n,l;
cin>>n;
for(int www=0;www<n;www++){
cin>>s;
l=s.length();
int nu=1,key;
key=s[0]-'0';


for(int j=0;j<l-1;j++){
if(s[j]!=s[j+1]){
p(nu,key);
nu=1;
key=s[j+1]-'0';
}
else{
nu++;
}

}
p(nu,key);
cout<<endl;
}
return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <string>

using namespace std;

int main()
{
	string bs[10]={
		"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz",
	};
	
	int tc; scanf("%d",&tc);
	while(tc--){
		char s[1025]; scanf("%s",s);
		int n=strlen(s);
		for(int i=0,j;i<n;i=j+1){
			string& b=bs[s[i]-'0'];
			for(j=i;j<n && s[j]>'0';j++);
			if(j==i) continue;
			putchar(b[(j-1-i)%b.size()]);
		}
		puts("");
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)

#define vi vector<int>
#define pb push_back

typedef long long ll;
using namespace std;


int main(){
    char d1[5] = {'.',',','!','?',' '};
    int n;
    while(cin >> n) {
        rep(i,n){
            string ar;
            cin >> ar;
            int cnt = 0;
            rep(j,ar.size()){
                if(ar[j + 1] != '0' && ar[j] != '0') {
                    cnt++;
                }else{
                    char c;
                    if(ar[j] == '0') continue;
                    else if(ar[j] == '1') c = d1[cnt % 5];
                    else if(ar[j] == '2') c = 'a' + (cnt % 3);
                    else if(ar[j] == '3') c = 'd' + (cnt % 3);
                    else if(ar[j] == '4') c = 'g' + (cnt % 3);
                    else if(ar[j] == '5') c = 'j' + (cnt % 3);
                    else if(ar[j] == '6') c = 'm' + (cnt % 3);
                    else if(ar[j] == '7') c = 'p' + (cnt % 4);
                    else if(ar[j] == '8') c = 't' + (cnt % 3);
                    else if(ar[j] == '9') c = 'w' + (cnt % 4);
                    cout << c;
                    cnt = 0;
                }
            }
            cout << endl;
        }
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	string strs[9]={{".,!? "},{"abc"},{"def"},{"ghi"},{"jkl"},{"mno"},{"pqrs"},{"tuv"},{"wxyz"}};
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string ans="",tmp;
		cin>>tmp;
		int a=0,b=0;//aがb回押された
		for(int j=0;j<tmp.size();j++){
			if(tmp[j]=='0'&&b>=1){
			ans+=strs[a-1][(b+strs[a-1].size()-1)%strs[a-1].size()];
			a=0,b=0;
			}
			if(tmp[j]=='0')continue;
			else {
				a=tmp[j]-'0';
				b++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <string>
#include <vector>

void make_table(std::vector<std::vector<char> > &table) {
    int i;
    int j;
    table[1].push_back(46); 
    table[1].push_back(44); 
    table[1].push_back(33); 
    table[1].push_back(63); 
    table[1].push_back(32); 
    for (i = 2; i <= 7; i++) {
        for (j = 0; j <= 2; j++) {
            table[i].push_back(97 + 3 * (i - 2) + j); 
        }
    }
    table[7].push_back(115);
    for (i = 8; i <= 9; i++) {
        for (j = 0; j <= 2; j++) {
            table[i].push_back(116 + 3 * (i - 8) + j); 
        }
    }
    table[9].push_back(122);
}

int main(void) {
    int n;
    std::string s;
    const char* c;
    char now_num;
    int now_count;
    std::vector<std::vector<char> >  table(10, std::vector<char>());
    make_table(table);

    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> s;
        c = s.c_str();
        now_count = 0;
        now_num = c[0];
        //std::cout << "SSIZE = " << s.size() << std::endl;
        for (int j = 0; j < s.size(); j++) {
            if (c[j] == now_num) {
                now_count++;
            } else {
                if (c[j] == '0') {
                    //std::cout << "C = " << c[j] << std::endl;
                    //std::cout << "NUM = " << now_num << std::endl;
                    //std::cout << "COUNT = " << now_count << std::endl;
                    int amari = now_count % table[(int)now_num - 48].size() - 1;
                    if (amari == -1) {
                        amari += table[(int)now_num - 48].size();
                    }
                    std::cout << table[(int)now_num - 48][amari];
                }
                if (j != s.size() - 1) {
                    now_num = c[j];
                }
                now_count = 1;
            }
        }
        std::cout << std::endl;
    }

    return EXIT_SUCCESS;
}