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<iostream>
#include<string>
using namespace std ;

char table[9][6] = {
	{'.',',','!','?',' '} , // 5
	{'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'} , // 4
	{'t','u','v','0','0'} ,
	{'w','x','y','z','0'} // 4
} ;

int main(){
	
	int n ;
	string s ;
	cin >> n ;
	for( int i=0 ; i<n ; i++ ){
		cin >> s ;
		for( int j=0 ; j<s.size() ; j++ ){
			int cnt = 0 , p = 3 ;
			char a = s[j] ;
			if( a == '0' ) continue ;
			if( a == '1' ) p = 5 ;
			if( a == '7' || a == '9' ) p = 4 ;
			for( j+=1 ; j<s.size() ; j++ ){
				if( s[j] == a ) cnt++ ;
				if( s[j] == '0' ) break ;
			}
			cout << table[a-'0'-1][cnt%p] ;
		}
		cout << endl ;
	}
	
return 0 ;
}

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