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 <vector>
#include <string>

using namespace std;

const vector<string> keys = {
    "",
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};

int main() {
    int C;
    cin >> C;

    while (C-- > 0) {
        string s;
        cin >> s;

        int pos = 0;
        string res = "";
        for (int i = 0; i < s.length() - 1; i++) {
            int k = stoi(s.substr(i, 1));
            if (s[i] == s[i + 1] && k != 0) {
                pos = (pos + 1) % keys[k].length();
            } else {
                res += keys[k][pos];
                pos = 0;
            }
        }

        cout << res << endl;
    }
}

C++: #include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;
int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		string key[]={".,!?, ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
		string input;
		cin>>input;
		stringstream b(input);
		int num=0,count=0;
		while(1){
			char c;
			if(b>>c)break;
			int input=c-'0';
			if(input!=0){
				count++;
				num=input;
			}
			else {
				if(count!=0)
					cout<<key[num-1][(count-1)%key[num-1].size()];
				num=0;count=0;
			}
		}
		cout<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)











int main(){
    string c[9] = {
        ".,!? ",
        "abc",
        "def",
        "ghi",
        "jkl",
        "mno",
        "pqrs",
        "tuv",
        "wxyz"
    };
    int t;
    cin >> t;
    REP(ttt, t){
        string s;
        cin >> s;
        string ans;
        ll k = -1, cnt = -1;
        REP(i, s.size()){
            if(s[i] != '0'){
                cnt++;
                k = s[i] - '1';
            }
            else{
                if(k == -1) continue;
                ans += c[k][cnt % c[k].size()];
                k = -1;
                cnt = -1;
            }
        }
        cout << ans << endl;
    }
}

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

#define INF 1001001

char data[][5] = { 	{'.', ',', '!', '?', ' '},
					{'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'} };
int num[] = {5, 3, 3, 3, 3, 3, 4 ,3, 4};

int main(void)
{
	int n;
	cin >> n;
	while (n--){
		string str, ret = "";
		bool flag = false;
		cin >> str;
		int cnt = -1, now = -1;
		for (int i = 0; i < (int)str.length(); i++){
			if (str[i] == '0' && flag){
				ret += data[now-1][cnt % num[now-1]];
				cnt = -1;
				now = -1;
				flag = false;
			}
			else if (str[i] != '0'){
				now = str[i] - '0';
				cnt++;
				flag = true;
			}
		}
		cout << ret << endl;
	}

	return 0;
}

C++: #include<cstdio>

using namespace std;

int main(){
	char *dic[]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	int len[]={-1,5,3,3,3,3,3,4,3,4};
	int n;	scanf("%d",&n);
	while(n--){
		char s[1025];	scanf("%s",s);
		char bef='@';
		int cnt=0;
		for(int i=0;s[i];i++){
			if(s[i]=='0'){
				if(cnt>0)	putchar(dic[bef-'0'][(cnt-1)%len[bef-'0']]);
				cnt=0;
				bef='@';
			}
			else{
				cnt++;
				bef=s[i];
			}
		}
		putchar('\n');
	}
	return 0;
}

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

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

void solve()
{
	int N;
	cin >> N;
	for(int i = 0; i < N; ++i)
	{
		string s;
		cin >> s;
		for(int j = 0; j < s.size(); ++j)
		{
			int pos = j;
			int c = 0;
			if(s[pos] == '0')
			{
				continue;
			}
			else
			{
				c = s[pos] - '0';
			}
			bool zero_flag = true;
			while(s[pos] != '0')
			{
				++pos;
				if(pos >= s.size())
				{
					zero_flag = false;
					break;
				}
			}
			if(!zero_flag)
			{
				break;
			}
			if(pos > j)
			{
				--pos;
			}
			cout << character[c][(pos - j) % character[c].size()];
			j = pos;
		}
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}