Go: // Keitai Message
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2006&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var table = []string{
	"",
	".,!? ",
	"abc",
	"def",
	"ghi",
	"jkl",
	"mno",
	"pqrs",
	"tuv",
	"wxyz",
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)

	for i := 0; i < n; i++ {
		message := nextString(sc)
		currentButton, count := 0, 0
		for _, word := range message {
			// 確定の処理を書く
			if word == '0' {
				if currentButton == 0 {
					count = 0
					continue
				}
				mod := len(table[currentButton])
				tmp := table[currentButton][(count-1)%mod]
				currentButton, count = 0, 0
				fmt.Printf("%c", tmp)
			} else {
				count++
				currentButton = int(word) - 48 // '0'はASCIIで48
			}
		}
		fmt.Println()
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int n;

map<char, vector<char>> mp = {
   {'1', {'.', ',', '!', '?', ' '}},
   {'2', {'a', 'b', 'c'}},
   {'3', {'d', 'e', 'f'}},
   {'4', {'g', 'h', 'i'}},
   {'5', {'j', 'k', 'l'}},
   {'6', {'m', 'n', 'o'}},
   {'7', {'p', 'q', 'r', 's'}},
   {'8', {'t', 'u', 'v'}},
   {'9', {'w', 'x', 'y', 'z'}},
};

void solve() {
   debug(mp['1'][0])
   debug(mp['1'][1])
   debug(mp['1'][2])

   exit(0);
}

int main() {
   // solve();
   cin >> n;
   while (n--) {
      string s;
      cin >> s;

      string ans = "";
      int size = s.size();
      for (int i = 0; i < size; i++) {
         if (s[i] == '0') continue;
         int cnt = 0;
         int idx = i;
         repp (j, i, size) {
            if (s[i] != s[j]) break;
            idx = j;
            cnt++;
         }
         int tSize = mp[s[i]].size();
         // printf("mp[%c][%d], %d\n", s[i], cnt%tSize, tSize);
         cnt--;
         if (cnt >= 0) {
            char c = mp[s[i]][cnt % tSize];
            ans += c;
         }
         i = idx;
      }

      cout << ans << endl;
   }

   return 0;
}

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;
}