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 <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
	char inputString[80],outputString[80], hoge[2];
	char str;//êIÉê¶ªf[^ðÛ·éÏ
	int length,count,push,index,dataSet;
	int p[9][5] = { //e{^ðµ½Æ«ÌÏÚð ç©¶ßpÓ(óÌvfÍ@É·é)
		{'.' , ',' , '!' , '?' , ' '},
		{'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' , '@'},
	}; 
	scanf("%d", &dataSet);//ßÉf[^ZbgðüÍ

	for(int i=0 ; i<dataSet ; i++){//f[^ZbgÌ¾¯üÍ³¹é
		//ÏÌú»
		count = 0;
		index = 0;
		push  = 0;
		str   = 0;

		scanf("%s", inputString);//0-9Ì¶ÌÀÑüÍ

		length = strlen( inputString );//üÍ¶Ì·³ðßé
		
		for(int i=0 ; i<length ; i++){//ê¶¸Â¶Ì·³ª¾¯²×é

			//¶ðlÉÏ··é(Ï·µ½0-9ª»ÌÜÜ¶ÌîñðÂzñÌY¦ÉÎ)
			hoge[0] = inputString[i];
			push = atoi(hoge);

			if(push==0){//mè{^:0¾Á½ç
				count = 0;
				if(str!=0){
					//êIÉÛ¶µÄ¢½¶ð¦ÉÇÁ
					outputString[index] = str;
					outputString[index+1] = '\0';
					str = 0;
					index++;
				}
			}
			else{//0ÈOÌ{^¾Á½ç

				//êIÉ»ÝÌ¶ðÛ¶
				str = p[push-1][count];
				//{^ðµ½ñðâ·
				count++;
				if(p[push-1][count]=='@' || count==5){
					count = 0;//{^ðµ½ñð0É·é
				}
			}
		}

		//¦Ì¶ñoÍ
		printf("%s \n", outputString );
	}

	return 0;
}

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

int main(void){
    const char character[][] = {{},
    {'.', ',', '!', '?', ' '},
    {'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 n;
    string s;
    for(int i = 0; i < n; i++){
        cin >> s;
        int index;
        for(index = i; s[index] != '0'; index++);
        int length = index - i;
        cout << character[s[i] - '0'][length / sizeof(character[s[i] - '0'] / character[s[i] - '0'][0])];
        i = index;
    }
    cout << endl;
    return 0;
}

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

char a[5] = {'.', ',', '!', '?', ' '};

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		string str;
		cin >> str;
		int t = 0, s = -1;
		for(int j = 0; j < str.size(); j++){
			if(str[j] == '0'){
				if(t == 0) continue;
				if(t == 1){
					s %= 5;
					cout << a[s];
				} else if(t <= 6){
					char o = 'a';
					s %= 3;
					o += s + 3*(t-2);
					cout << o;
				} else if(t == 7){
					char o = 'a';
					s %= 4;
					o += s+3*(t-2);
					cout << o;
				} else if(t == 8){
					char o = 'a';
					s %= 3;
					o += s+19;
					cout << o;
				} else{
					char o = 'a';
					s %= 4;
					o += s+22;
					cout << o;
				}
				t = 0;
				s = -1;
			} else{
				t = str[j]-'0';
				s++;
			}
		}
		cout << endl;
	}
}

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

int main() {
    vector<string> v;
    v.push_back(".,!? ");
    v.push_back("abc");
    v.push_back("def");
    v.push_back("ghi");
    v.push_back("jkl");
    v.push_back("mno");
    v.push_back("pqrs");
    v.push_back("tuv");
    v.push_back("wxyz");

    int N;
    cin >> N;
    while (N--) {
        string s;
        cin >> s;
        int x = 0, cnt = 0;
        for (char c : s) {
            if (c == '0') {
                x--;
                cnt--;
                if (x != -1) {
                    cout << v[x][cnt % v[x].size()];
                }
                x = 0;
            } else {
                if (x == 0) {
                    x = c - '0';
                    cnt = 1;
                } else {
                    cnt++;
                }
            }
        }
        cout << endl;
    }
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	string a,b;
	while (cin>>a){
		int la=a.size();
		int c=0;
		for(int i=0;i<la;i++){
			if(a[i]=='0'){
				if(b=="1"){
					c=c%5;
					if(c==1) cout<<".";
					if(c==2) cout<<",";
					if(c==3) cout<<"!";
					if(c==4) cout<<"?";
					if(c==0) cout<<" "; 
				}
				if(b=="2"){
					c=c%3;
					if(c==1) cout<<"a";
					if(c==2) cout<<"b";
					if(c==0) cout<<"c";
				}
				if(b=="3"){
					c=c%3;
					if(c==1) cout<<"d";
					if(c==2) cout<<"e";
					if(c==0) cout<<"f";
				}
				if(b=="4"){
					c=c%3;
					if(c==1) cout<<"g";
					if(c==2) cout<<"h";
					if(c==0) cout<<"i";
				}
				if(b=="5"){
					c=c%3;
					if(c==1) cout<<"j";
					if(c==2) cout<<"k";
					if(c==0) cout<<"l";
				}
				if(b=="6"){
					c=c%3;
					if(c==1) cout<<"m";
					if(c==2) cout<<"n";
					if(c==0) cout<<"o";
				}
				if(b=="7"){
					c=c%4;
					if(c==1) cout<<"p";
					if(c==2) cout<<"q";
					if(c==3) cout<<"r";
					if(c==0) cout<<"s";
				}
				if(b=="8"){
					c=c%3;
					if(c==1) cout<<"t";
					if(c==2) cout<<"u";
					if(c==0) cout<<"v";
				}
				if(b=="9"){
					c=c%4;
					if(c==1) cout<<"w";
					if(c==2) cout<<"x";
					if(c==3) cout<<"y";
					if(c==0) cout<<"z";
				}
				c=0;
				b="0";
			}
			else{
				b=a[i];
				c++;
			}
		}
		cout<<endl;
	}
    return 0;
}

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

int main()
{
	int n, c;
	string key[] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	string input;
	char p;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> input;
		c = 0;
		p = '0';
		for (int j = 0; j < input.size(); j++) {
			if (input[j] == '0' && c != 0) {
				cout << key[p - '0'][(c - 1) % key[p - '0'].size()] << endl;
				c = 0;
			} else if (p == '0' && input[j] == '0'){
			} else if (input[j] == p) {
				c++;
			} else {
				c = 1;
			}
			p = input[j];
		}
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

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

signed main() {
	int n;
	cin >> n;
	rep(i, 0, n) {
		string s, ans = "";
		cin >> s;
		int now = 0, cnt = 0;
		rep(i, 0, s.size()) {
			if (s[i] =='0') {
				if (now == 0) continue;
				cnt %= t[now].size();
				ans += t[now][cnt];
				now = 0;
				cnt = 0;
			}
			else if (now == 0) {
				now = s[i] - '0';
				cnt = 0;
			}
			else if (now == s[i] - '0') {
				cnt++;
			}
			//cout << i << " " << now << " " << cnt << endl;
		}
		cout << ans << endl;
	}
}