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 <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	string b[10];
	b[1] = ".,!? ";
	b[2] = "abc";
	b[3] = "def";
	b[4] = "ghi";
	b[5] = "jkl";
	b[6] = "mno";
	b[7] = "pqrs";
	b[8] = "tuv";
	b[9] = "wxyz";
/*
	b[1][] = { '.', ',', '!', '?', ' ' };
	b[2][] = { 'a', 'b', 'c' };
	b[3][] = { 'd', 'e', 'f' };
	b[4][] = { 'g', 'h', 'i' };
	b[5][] = { 'j', 'k', 'l' };
	b[6][] = { 'm', 'n', 'o' };
	b[7][] = { 'p', 'q', 'r', 's' };
	b[8][] = { 't', 'u', 'v' };
	b[9][] = { 'w', 'x', 'y', 'z' };
*/
//	cut here before submit 
//	freopen ("testcase.KM", "r", stdin );
	int n;
	scanf ("%d", &n );
	while (n-- ){
		string mesg = "";
		cin >> mesg;
		int m = mesg.length();
		int c = -1, cnt = -1;
		string ans = "";
		rep (i, m ){
			if (mesg[i] != '0' ){
				c = (char)(mesg[i] - '0');
				cnt++;
			}else{
				if (c != -1 ){
//					if (cnt == 1 ) cnt--;
					ans += b[c][(cnt) % b[c].length() ];
				} // end if
				c = -1;
				cnt = -1;
			} // end if
		} // end rep
		cout << ans << endl;
	} // end loop
		
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main() {
	int a[1030];
	int k;
	stringstream sout;
	string b;
	int kari;
	while (cin >> b) {
		kari = 0;
		int rireki[10] = {0};
		k = b.size();
		for (int i = 0; i < k; i++) {
			sout.str("");
			sout.clear();
			sout << b[i];
			sout >> a[i];
		}
		for (int i = 0; i < k-1; i++) {
			if(a[i] != a[i+1] && a[i+1] == 0 && a[i] != 0) {
				kari = 1;
				if (a[i] == 1) {
					if(rireki[1] % 5 == 0) {
						printf(".");
					} else if (rireki[1] % 5 == 1) {
						printf(",");
					} else if (rireki[1] % 5 == 2) {
						printf("!");
					} else if (rireki[1] % 5 == 3) {
						printf("?");
					} else {
						printf(" ");
					}
					rireki[1] = 0;
				} else if (a[i] == 2) {
					//printf(" %d \n", rireki[2]);
					if(rireki[2] % 3 == 0) {
						printf("a");
					} else if (rireki[2] % 3 == 1) {
						printf("b");
					} else {
						printf("c");
					}
					rireki[2] = 0;
				} else if (a[i] == 3) {
					if (rireki[3] % 3 == 0) {
						printf("d");
					} else if (rireki[3] % 3 == 1) {
						printf("e");
					} else {
						printf("f");
					}
					rireki[3] = 0;
				} else if (a[i] == 4) {
					if (rireki[4] % 3 == 0) {
						printf("g");
					} else if (rireki[4] % 3 == 1) {
						printf("h");
					} else {
						printf("i");
					}
					rireki[4] = 0;
				} else if (a[i] == 5) {
					if (rireki[5] % 3 == 0) {
						printf("j");
					} else if (rireki[5] % 3 == 1) {
						printf("k");
					} else {
						printf("l");
					} 
					rireki[5] = 0;
				} else if (a[i] == 6) {
					if (rireki[6] % 3 == 0) {
						printf("m");
					} else if (rireki[6] % 3 == 1) {
						printf("n");
					} else {
						printf("o");
					}
					rireki[6] = 0;
				} else if (a[i] == 7) {
					if (rireki[7] % 4 == 0) {
						printf("p");
					} else if (rireki[7] % 4 == 1) {
						printf("q");
					} else if (rireki[7] % 4 == 2) {
						printf("r");
					} else {
						printf("s");
					}
					rireki[7] = 0;
				} else if (a[i] == 8) {
					if (rireki[8] % 3 == 0) {
						printf("t");
					} else if(rireki[8] % 3 == 1) {
						printf("u");
					} else {
						printf("v");
					}
					rireki[8] = 0;
				} else {
					if (rireki[9] % 4 == 0) {
						printf("w");
					} else if (rireki[9] % 4 == 1) {
						printf("x");
					} else if (rireki[9] % 4 == 2) {
						printf("y");
					} else {
						printf("z");
					}
					rireki[9] = 0;
				}
			} else {
				if (a[i] == 0 || (a[i] != a[i+1])) {
					rireki[a[i]] = 0;
					continue;
				}
				rireki[a[i]]++;
			}
		}
		if (kari == 1) {
			printf("\n");
			}
	}
	return 0;
}

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

int main(){
	string chg[] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		string s;
		cin >> s;
		int now = -1,num = -1;
		for(int j = 0;j < s.length();j++){
			if(s[j] == '0'){
				if(now == -1 && num == -1) continue;
				cout << chg[now][num % chg[now].length()];
				num = -1;
				now = -1;
			}else{
				now = s[j] - '1';
				num++;
			}
		}
		cout << endl;
	}
	return 0;
}

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

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdlib>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
using namespace std;
bool debug=true;

int main(){
  int n;
  string s[10]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};

  cin>>n;
  for(int i=0;i<n;i++){
    //cout<<"DEBUG"<<endl;
    string ss;
    cin>>ss;
    int cnt=0;
    for(int j=0;j<ss.size();j++){
      if(ss[j]=='0'&&cnt!=0){
	int x=int(ss[j-1])-48;
	//cout<<x<<endl;
	cout<<s[x][(cnt-1)%int(s[x].size())];
	cnt=0;
      }else if(ss[j]=='0'&&cnt==0){
	cnt=0;
      }else{
	cnt++;
      }
    }
    cout<<endl;
  }
  
  return 0;
}

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

int main(int argc, char *argv[])
{
    string map[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno",
        "pqrs", "tuv", "wxyz"};
    string line;
    int n, cnt, num;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> line;
        cnt = 0;
        for (int j = 0; j < line.length(); ++j) {
            if (line[j] == '0' && j != 0 && line[j - 1] != '0') {
                num = line[j - 1] - '0';
                cout << map[num][(cnt - 1) % map[num].length()];
                cnt = 0;
            } else if (line[j]) {
                cnt++;
            }
        }
        cout << endl;
    }
    return 0;
}