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>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;
typedef pair<int, int> P;

/** Problem2006 : Keitai Message **/
int main()
{
	string list[10] = {" ", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	int l[10] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4};
	int n;
	cin >> n;
	rep(k, n) {
		string in, ans;
		cin >> in;
		int tmp=-1; char c=' ';
		rep(i, in.length()) {
			if (in[i]!='0') {
				tmp++; tmp%=l[in[i]-'0'];
				c = list[in[i]-'0'][tmp];
			} else {
				if (c != ' ')
					ans+=c;
				tmp=-1;
				c=' ';
			}
		}
		cout << ans << endl;
	}
}

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

int main(){
	const char C[10][6] = {
		{},
		{'.',',','!','?',' ', 5 },
		{'a','b','c', 0 , 0 , 3 },
		{'d','e','f', 0 , 0 , 3 },
		{'g','h','i', 0 , 0 , 3 },
		{'j','k','l', 0 , 0 , 3 },
		{'m','n','o', 0 , 0 , 3 },
		{'p','q','r','s', 0 , 4 },
		{'t','u','v', 0 , 0 , 3 },
		{'w','x','y','z', 0 , 4 },
	};
	int n;
	cin >> n;
	for(int i=0 ; i<n ; ++i ){
		char s[1025];
		cin >> s;
		char c = 0;
		int pos = -1;
		for(int j=0 ; s[j] ; ++j ){
			int button = s[j] - '0' ;
			if( button == 0 ){
				if( c != 0 ) cout << c ;

				pos = -1;
				c = 0;
			}else{
				pos++;
				c = C[ button ][ pos % (int)(C[button][5]) ];
			}
		}
		cout << endl;
	}
}

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

void solve(string s){
    
    vector<vector<char>> v;
    vector<char> tmp;
    tmp.push_back('.');
    tmp.push_back(',');
    tmp.push_back('!');
    tmp.push_back('?');
    tmp.push_back(' ');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('a');
    tmp.push_back('b');
    tmp.push_back('c');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('d');
    tmp.push_back('e');
    tmp.push_back('f');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('g');
    tmp.push_back('h');
    tmp.push_back('i');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('j');
    tmp.push_back('k');
    tmp.push_back('l');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('m');
    tmp.push_back('n');
    tmp.push_back('o');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('p');
    tmp.push_back('q');
    tmp.push_back('r');
    tmp.push_back('s');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('t');
    tmp.push_back('u');
    tmp.push_back('v');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('w');
    tmp.push_back('x');
    tmp.push_back('y');
    tmp.push_back('z');
    v.push_back(tmp);
    tmp.clear();
    
    int t;
    for(auto itr=s.begin()+1;itr!=s.end();itr++){
        if(*itr=='0'){
            if(*(itr-1)!='0'){
                t=*(itr-1)-'0';
                int count=0;
                for(auto it=itr-1;*it!='0';it--){
                    count++;
                    if(it==s.begin()||*(it-1)=='0'){
                        break;
                    }
                }
                cout<<v[t-1][(count-1)%v[t-1].size()];
                
            }
        }
    }
    cout<<endl;
    
}


int main(void){
    int n;
    cin>>n;
    string s;
    for(int i=0;i<n;i++){
        cin>>s;
        solve(s);
    }
    
}

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

int main(void)
{
	string S, message[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	int N, k;
	cin >> N;
	while (N--) {
		cin >> S;
		int count = -1, k = S[0] - '0';
		for (int i = 0; i < S.size(); i++) {
			if (S[i] == '0') {
				if (k != 0) {
					count %= message[k].size();
					cout << message[k][count];
				}
				k = S[i + 1] - '0';
				count = -1;
			}else {
				count++;
			}
		}
		cout << endl;
	}	
	return 0;
}

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

char b1[5]={'.' , ',' , '!' , '?' , ' '};
char b2[3]={'a' , 'b' , 'c'};
char b3[3]={'d' , 'e' , 'f'};
char b4[3]={'g' , 'h' , 'i'};
char b5[3]={'j' , 'k' , 'l'};
char b6[3]={'m' , 'n' , 'o'};
char b7[4]={'p' , 'q' , 'r' , 's'};
char b8[3]={'t' , 'u' , 'v'};
char b9[4]={'w' , 'x' , 'y' , 'z'};

int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		string in,out;
		cin>>in;
		int cnt=0;
		for(int i=0;i<in.size();i++)
		{
			if(in[i]==0&&cnt==0) continue;
			else if(in[i]!='0') cnt++;
			else
			{
				switch(in[i-1]){
					case '1':
						out+=b1[(cnt-1)%5];
						break;
					case '2':
						out+=b2[(cnt-1)%3];
						break;
					case '3':
						out+=b3[(cnt-1)%3];
						break;
					case '4':
						out+=b4[(cnt-1)%3];
						break;
					case '5':
						out+=b5[(cnt-1)%3];
						break;
					case '6':
						out+=b6[(cnt-1)%3];
						break;
					case '7':
						out+=b7[(cnt-1)%4];
						break;
					case '8':
						out+=b8[(cnt-1)%3];
						break;
					case '9':
						out+=b9[(cnt-1)%4];
						break;
				}
				cnt=0;
			}
		}
		cout<<out<<endl;
	}
	return 0;
}

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

int main(void) {

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

    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        string s; cin >> s;
        string str = "";
        pair<char, int> num;
        num.first = ' ';
        num.second = -1;

        for (auto x : s) {
            if (x == '0') {
                if (num.first == ' ') continue;

                int bi = num.first - '0';
                str += button[bi][num.second % button[bi].size()];
                cout << "### str = " << str << endl;

                num.first = ' ';
                num.second = -1;
                continue;
            }

            num.first = x;
            num.second++;
        }

        cout << str << endl;
    }

    return 0;
}

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

typedef struct {
	int N;
	char C[6];
} INPUT;

INPUT input[10] = {
	{0, ""},
	{5, ".,!? "},
	{3, "abc"},
	{3, "def"},
	{3, "ghi"},
	{3, "jkl"},
	{3, "mno"},
	{4, "pqrs"},
	{3, "tuv"},
	{4, "wxyz"}
};

int main()
{
	int N;
	
	scanf("%d", &N);
	for (int i = 0; i < N; i++){
		char str[2048];
		scanf("%s", str);
		
		int j = 0;
		char now = 0;
		int num = 0;
		while (str[j] != '\0'){
			if (str[j] == '0'){
				if (now != 0){
					printf("%c", input[now - '0'].C[num % input[now - '0'].N ] );
				}
				now = 0;
				num = 0;
			}
			else {
				if (now == 0){
					now = str[j];
				}
				else {
					num++;
				}
			}
			j++;
		}
		
		puts("");
	}
	
	return 0;
}