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 _GRIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

#define int long long

vector<vector<char> > buttons = {
    {'.',',','!','?'},
    {'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'}
};

signed main()
{
    int n;
    cin >> n;
    while(n--) {
        string s;
        cin >> s;
        string ans = "";
        int bt = 0;
        int cnt = 0;
        for(int i=0; i<s.size(); ++i) {
            int num = s[i] - '0';
            if(num==0) {
                if(bt==0) continue;
                if(bt==1||bt==7||bt==9) {
                    cnt %= 4;
                    if(cnt==0) cnt = 3;
                    else cnt--;
                }
                else {
                    cnt %= 3;
                    if(cnt==0) cnt = 2;
                    else cnt--;
                }
                ans += buttons[bt-1][cnt];
                bt = 0;
                cnt = 0;
                continue;
            }
            if(bt!=num) {
                bt = num;
                cnt = 1;
            }
            else cnt++;
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	vector<string> assign(10);
	assign[1] = ".,!? ";
	assign[2] = "abc";
	assign[3] = "def";
	assign[4] = "ghi";
	assign[5] = "jkl";
	assign[6] = "mno";
	assign[7] = "pqrs";
	assign[8] = "tuv";
	assign[9] = "wxyz";
	
	for(int i = 0; i < n; ++i) {
		string input, output;
		cin >> input;

		int cnt = 0;
		string candidate = "";
		for(int j = 0; j < (int)input.size(); ++j) {
			if(input[j] == '0') {
				output += candidate;
				candidate = "";
				cnt = 0;
			}
			else {
				const string& str = assign[input[j] - '0'];
				candidate = str[cnt];
				cnt = (cnt + 1) % str.size();
			}
		}

		cout << output << endl;
	}

	return EXIT_SUCCESS;
}

C++: #include<stdio.h>
#include<string.h>
main(){
    int N;
    char S[1025];
    scanf("%d",&N);
    char str[][6] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
    for(int i = 0;i < N;i++){
        scanf("%s",S);
        int num = 0;//?????¨??\??????????????????
        int count = 0;
        for(int j = 0;j < strlen(S);j++){
            if(S[j] != '0'){num = S[j] - '0';}
            if(S[j] == '0' && num == 0){continue;}
            if(S[j] == S[j+1]){
                count++;
                continue;
            }
            printf("%c",str[num-1][count%(strlen(str[num-1]))]);
            count = 0;
            num = 0;
        }
        printf("\n");
    }
}

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

using std::cin;
using std::cout;
using std::endl;

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

char out_keitai(int num, int count) {
	if (num == 1) {
		if (count%5 != 0) {
			return keitai[num-1][(count%5)-1];
		}else {
			return keitai[num-1][4];
		}
	}else if (num == 7 || num == 9) {
		if (count%4 != 0) {
			return keitai[num-1][(count%4)-1];
		}else {
			return keitai[num-1][3];
		}
	}else {
		if (count%3 != 0) {
			return keitai[num-1][(count%3)-1];
		}else {
			return keitai[num-1][2];
		}
	}
}
int main(void) {
	int n;
	char inp;
	std::string str;

	getline(cin, str);
	n = atoi(str.c_str());

	for (int i = 0; i < n; i++) {
		getline(cin, str);
		int num;
		int count = 0;
		for (int j = 0; j < str.length(); j++) {
			std::string dstr;
			dstr = str.substr(j,1);
			num = atoi(dstr.c_str());
			if (num != 0) {
				count++;
				int seq = 1;
				int next_num;
				while (seq) {
					dstr = str.substr(j+1,1);
					next_num = atoi(dstr.c_str());
					if (num == next_num) {
						count++;
						j++;
					}else {
						seq = 0;
						cout << out_keitai(num,count);
						count = 0;
					}
				}	
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
string s,data[9]={
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};
int n,i,p,t;
int main(){
	cin>>n;while(n--){
		cin>>s,t=1,p=s[0]-'0';
		for(i=1;i<s.length();i++){
			if(s[i]=='0'){if(p!=0)cout<<data[p-1][(t-1)%data[p-1].length()];i++,p=s[i]-'0',t=1;}else if(p==0)p=s[i]-'0';
			else t++;
		}cout<<endl;
	}
}