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;
int main(){
  vector<char> a[10];
  vector<char> ans;
  a[0].push_back('.');
  a[0].push_back(',');
  a[0].push_back('!');
  a[0].push_back('?');
  a[0].push_back(' ');
  a[1].push_back('a');
  a[1].push_back('b');
  a[1].push_back('c');
  a[2].push_back('d');
  a[2].push_back('e');
  a[2].push_back('f');
  a[3].push_back('g');
  a[3].push_back('h');
  a[3].push_back('i');
  a[4].push_back('j');
  a[4].push_back('k');
  a[4].push_back('l');
  a[5].push_back('m');
  a[5].push_back('n');
  a[5].push_back('o');
  a[6].push_back('p');
  a[6].push_back('q');
  a[6].push_back('r');
  a[6].push_back('s');
  a[7].push_back('t');
  a[7].push_back('u');
  a[7].push_back('v');
  a[8].push_back('w');
  a[8].push_back('x');
  a[8].push_back('y');
  a[8].push_back('z');
  char x;
  int n;
  cin>>n;
  
  scanf("%c",&x);
  int memo=-1,count=-1,z=0;
  for(int i=0;i<n;i++){
    while(1){
      scanf("%c",&x);
      if('0'<=x &&x<='9'){
	z=x-'0';
	if(z!=0){
	  memo=z;
	  count++;
	}
	else{
	  memo--;
	  if(memo==-2){
	    memo=-1;
	    continue;
	  }
	  count%=a[memo].size();
	  cout<<a[memo][count];
	  memo=-1;
	  count=-1;
	}
      }
      else{
	cout<<endl;
      break;
      }
    }
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007


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



int main(){
	int n;
	string s;
	cin>>n;
	rep(i,n){
		cin>>s;
		string a;
		rep(j,s.size()){
			if(s[j]!='0'){
				char c=t[s[j]-'0'][0];
				int k=0;
				while(1){
					j++;
					if(j>s.size())break;
					if(s[j]=='0'){
						a+=c;
						break;
					}
					k=(k+1)%t[s[j]-'0'].size();
					c=t[s[j]-'0'][k];
				}
			}
		}
		cout<<a<<endl;
	}
}

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

int key[10];

// プロトタイプ宣言
void Reset(void);
char Output(int);
// ここまで

int main(){
	Reset();

	int n;	cin>>n;
	for(int i=0;i<n;i++){
		string ans="";
		string s;
		cin>>s;
		for(int j=0;j<s.length();j++){
			int num=s[j]-'0';
			//printf("<%d>\n",num);

			if(num==0){
				for(int k=1;k<=9;k++){
					if(key[k]<0)continue;
					else ans+=Output(k);
				}
				Reset();
			}else{
				key[num]++;
			}
		}

		cout<<ans<<endl;
	}


	return 0;
}



void Reset(void){ for(int i=0;i<10;i++) key[i]=-1; }
char Output(int num){
	char word[10][5]={
		{'A','B','C','D','E'},// 使わない
		{'.',',','!','?',' '},
		{'a','b','c','F','G'},
		{'d','e','f','H','I'},
		{'g','h','i','J','K'},
		{'j','k','l','L','M'},
		{'m','n','o','N','O'},
		{'p','q','r','s','P'},
		{'t','u','v','Q','R'},
		{'w','x','y','z','S'}};

	int tmp=key[num];
	switch(num){
		case 1:
			tmp%=5;
			break;
		case 7:
		case 9:
			tmp%=4;
			break;
		default:
			tmp%=3;
			break;
	}

	return word[num][tmp];
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  string tenkey[10] = {".,!? ",
                     "abc",
                     "def",
                     "ghi",
                     "jkl",
                     "mno",
                     "pqrs",
                     "tuv",
                     "wxyz"};
  cin >> n;

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;

    for (int j = 0; j < s.size(); j++) {
      int count = -1;
      int num = s[j] - '0';
      while (s[j] != '0') {
        count++;
        j++;
      }
      //cout << "num-1 = " << num-1 << endl;                                                                                                      
      //cout << "count = " << count << endl;                                                                                                      
      if (count >= 0) {
        //cout << "tenkey[num-1].size() = " << tenkey[num-1].size() << endl;                                                                      
        cout << tenkey[num-1][count % tenkey[num-1].size()];
      }
    }
    cout << endl;
  }
  return 0;
}

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

int main(){
    int n;
    char ans[100];
    char s[1100];
    int value;
    int h = 0,w,cnt;
    bool judge;
    char tmp[9][6] = {{".,!? "},{"abc"},{"def"},{"ghi"},{"jkl"},{"mno"},{"pqrs"},{"tuv"},
        {"wxyz"}};
    cin >> n;
    while(n--){
        value = 0;
        memset(ans,0,sizeof(ans));
        memset(s,0,sizeof(s));
        cin >> s;
        for(int i=0;i<strlen(s);i++){
            cnt = 0;
            h = 0;
            while(1){
                if(s[i] == '0') break;
                h = s[i]%'0';
                cnt++;  
                i++;
            }
            w = cnt-1;
            judge = false;
            switch (h-1){
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                case 7:
                    ans[value] = tmp[h-1][w%3];
                    judge = true;
                    break;
                case 6:
                case 8:
                    ans[value] = tmp[h-1][w%4];
                    judge = true;
                    break;
                case 0:
                    ans[value] = tmp[h-1][w%5];
                    judge = true;
            }
            if(judge) value++;
        }
        cout << ans << endl;
    }
}

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

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

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
int main()
{
	int n, i, j, k, c, d, x;
	char s[1025], t[10][6] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> s;
		for (j = x = 0, d = 0; j < strlen(s); j++, d = c)
		{
			c = s[j] - '0';
			if (c == 0 && d != 0)
				cout << t[d-1][x%strlen(t[d-1])];
			else if (d == c)
				x++;
			else
				x = 0;
		}
		cout << endl;
	}
}