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++: //{{{
#define DEF
#ifdef DEF
#include <iostream>
#include <algorithm>
#include <functional>
#include <stack>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <cstring>
#include <cmath>
#include <set>
#include <deque>

//-----------------------------------------------------
#define mrepp(i,n,x)  for(int i = n-1; i >= x; i--)
#define mrep(i,n) mrepp(i,n,0)
#define repp(i,x,n)  for(int i = x; i < n; i++)
#define rep(i,n) repp(i,0,n)

using namespace std;
typedef pair<int, int> Pii;
typedef long long int llint;

template<typename T>
void display(T &t, int start_x, int start_y, int end_x, int end_y) {
	cout << "===================" << endl;
	repp(i,start_y,end_y) {
		repp(j,start_x,end_x)
			printf("%4d:", t[i][j]);
		cout << endl;
	}
	cout << "===================" << endl;
}

//-----------------------------------------------------
#endif
//}}}

char moji[10][6] = {
		{},
		{5,'.',',','!','?',' '},
		{3,'a','b','c'},
		{3,'d','e','f'},
		{3,'g','h','i'},
		{3,'j','k','l'},
		{3,'m','n','o'},
		{4,'p','q','r','s'},
		{3,'t','u','v'},
		{4,'w','x','y','z'},
};

void solve() {

}

int main(void) {

	int n;
	cin >> n;
	rep(g,n){
		string s;
		cin >> s;
		int flag = 0;
		int count = -1;
		int a;
		rep(h,(int)s.size()){
			if(s[h]=='0' && !flag)continue;
			if(s[h]=='0' && flag){
				flag = 0;
				count = count % moji[a][0] + 1;
				cout << moji[a][count] << flush;
				count = -1;
			}
			else{
				a = s[h]-'0';
				count++;
				flag = 1;
			}
		}
		cout << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main(){
  int n,i,j,k,p;
  string str;
  cin>>n;
  for(j=0;j<n;j++){
    cin >> str;
    p=0;
    char c;
    for(i=0;i<str.size();i++){
      if(str[i]=='0'){
	if(p!=0){
	  if(c=='1'){
	    if(p%5==1) cout << '.';
	    if(p%5==2) cout << ',';
	    if(p%5==3) cout << '!';
	    if(p%5==4) cout << '?';
	    if(p%5==4) cout << ' ';
	  }
	  if(c=='2'){
	    printf("%c", ('a'+(p-1)%3));
	  }
	  if(c=='3'){
	    printf("%c", ('d'+(p-1)%3));
	  }
	  if(c=='4'){
	    printf("%c", ('g'+(p-1)%3));
	  }
	  if(c=='5'){
	    printf("%c", ('j'+(p-1)%3));
	  }
	  if(c=='6'){
	   printf("%c", ('m'+(p-1)%3));
	  }
	  if(c=='7'){
	    printf("%c", ('p'+(p-1)%4));
	  }
	  if(c=='8'){
	    printf("%c", ('t'+(p-1)%3));
	  }
	  if(c=='9'){
	    printf("%c", ('w'+(p-1)%4));
	  }
	}
	p=0;
      }else{
	c=str[i];
	p++;
      }
      
    }
    cout << endl;
  }
  return 0;
}

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

char mes(char c){
    int n = c -'0';
    if(n==2)return 'a';
    else if(n==3)return 'd';
    else if(n==4)return 'g';
    else if(n==5)return 'j';
    else if(n==6)return 'm';
    else if(n==7)return 'p';
    else if(n==8)return 't';
    else return 'w';
}


int main(){
    long long n;
    cin >> n;
    for(int i=0;i<n;i++){
        string str;
        cin >> str;
        int cou = 0;    
        for(int j=0;j<str.size();j++){
           if(str[j]=='0' && str[j-1]!='0' && j!=0){
                    cou--;
                    if(str[j-1]!='1'){
                        char a = mes(str[j-1]);
                        if(str[j-1]=='7'||str[j-1]=='9')printf("%c",a + (cou)%4);
                        else printf("%c",a+cou%3);
                    }else{
                       cou%=5;
                        if(!cou)cout << ".";
                        else if(cou==1)cout << ",";
                        else if(cou==2)cout << "!";
                        else if(cou==3)cout << "?";
                        else cout << " ";
                    }
                cou = 0;
           }else if(str[j]!='0'){
               cou++;
           }
        }
        cout << endl;
    }
}