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>

using namespace std;

int main(){
	string s;
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		char a;
		cin >> s;
		char t = '~';
		for(int j = 0; j < s.length(); ++j){
			a = s[j];
			switch(a){
				case '1':
					if(t == '~' || t == ' '){
						t = '.';
					}else if(t == '.'){
						t = ',';
					}else if(t == ','){
						t = '!';
					}else if(t == '!'){
						t = '?';
					}else if(t == '?'){
						t = ' ';
					}
					break;
				case '2':
					if(t == '~' || t == 'c'){
						t = 'a';
					}else{
						t++;
					}
					break;
				case '3':
					if(t == '~' || t == 'f'){
						t = 'd';
					}else{
						t++;
					}
					break;
				case '4':
					if(t == '~' || t == 'i'){
						t = 'g';
					}else{
						t++;
					}
					break;
				case '5':
					if(t == '~' || t == 'l'){
						t = 'j';
					}else{
						t++;
					}
					break;
				case '6':
					if(t == '~' || t == 'o'){
						t = 'm';
					}else{
						t++;
					}
					break;
				case '7':
					if(t == '~' || t == 's'){
						t = 'p';
					}else{
						t++;
					}
					break;
				case '8':
					if(t == '~' || t == 'v'){
						t = 't';
					}else{
						t++;
					}
					break;
				case '9':
					if(t == '~' || t == 'z'){
						t = 'w';
					}else{
						t++;
					}
					break;
				case '0':
					if(t != '~'){
						cout << t;
						t = '~';
					}
					break;
			}
		}
		cout << endl;
	}
}

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

#include<vector>

int main(){
	int n;
	cin>>n;
	
	/*
	char a1[]={".",",","!","?"," "};
	char a2[]={"a","b","c"};
	char a3[]={"d","e","f"};
	char a4[]={"g","h","i"};
	char a5[]={"j","k","l"};
	char a6[]={"m","n","o"};
	char a7[]={"p","q","r","s"};
	char a8[]={"t","u","v"};
	char a9[]={"w","x","y","z"};
	*/
	
	vector<string> a(10);
	a[1]=".,!? ";
	a[2]="abc";
	a[3]="def";
	a[4]="ghi";
	a[5]="jkl";
	a[6]="mno";
	a[7]="pqrs";
	a[8]="tuv";
	a[9]="wxyz";
	
	for(int k=0;k<n;k++){
		string s;
		cin>>s;
		int cnt=0;
		int mj=0;
		for(int i=0;i<s.size();i++){
			if(s[i]-'0'==0){
				if(mj!=0){
				cout<<a[mj][cnt%a[mj].size()];
				cnt=0;
				mj=0;
				}
			}else{
				if(s[i]-'0'==mj){
					cnt++;
				}else{
					mj=s[i]-'0';
				}
			}
		}
		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 = 1;    
        if(str[0]=='0')cou=0;
        for(int j=1;j<str.size();j++){
           if(str[j]=='0' && str[j-1]!='0'){
                    if(cou)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;
    }
}

C++: #include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;

int n;

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

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		string t[1000];
		bool flag=0;
		int now=0;
		for(int j=0;j<(int)s.length();j++){
			if(s[j]=='0'){
				if(flag){
					now++;
					t[now]="";
					flag=0;
				}
			}else{
				t[now]+=s[j];
				flag=1;
			}
		}
		string ans="";
		for(int j=0;j<now;j++){
			int index=t[j][0]-'1';
			int index2=t[j].length()%temp[index].length();
			if(index2==0)index2=temp[index].length()-1;
			else index2--;
			ans+=temp[index][index2];
		}
		cout<<ans<<"\n";
	}
	return 0;
}

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

char hyo[9][5];

char moji(int char_, int count);

int main(void)
{
	int i1,i2;
	char c = 'a';
	char cc;
	string s;
	int n;
	int m;
	int count;

	/* syokika */
	for(i1=0;i1<9;i1++){	
		for(i2=0;i2<5;i2++){
			hyo[i1][i2] = '1';
//			cout << hyo[i1][i2];
		}
//		cout << endl;
	}


	/* hyo sakusei */
	hyo[0][0] = '.';
	hyo[0][1] = ',';
	hyo[0][2] = '!';
	hyo[0][3] = '?';
	hyo[0][4] = ' ';


	for( i1=1; i1<9; i1++){
		for(i2=0; i2<4; i2++){
			
			if(i2 == 3) {

				if( i1 == 6 || i1 == 8) {}
				else continue;
			}

			hyo[i1][i2] = c;
			c++;
//			cout << hyo[i1][i2] << " ";
		}
//		cout << endl;
	}



	cin >> n;

	for(i2=0;i2<n;i2++){


	//	cout << "s?" << endl;
		cin >> s;

		count = 0;
		m = 0;
		for(i1=0;i1<s.size();i1++){
		

			if( s[i1]=='0'){
				if(m != 0){
					cc = moji(m,count);
					count = 0;
					m = 0;
				    cout << cc;
				}
			}
			else{

				c = s[i1];
				m = c - 48;
				count++;
			}
		}


	}

/*	i1 = 0;
	count = 0;
	for(i1=0;i1<10;i1++){

//		char_ = s[i1];
		count++;

		if(s[i1] == 0){
			c = moji(char_, count);
			count = 0;
		}
	}

*/

//	c = moji(4,2);
//	cout << c;

	return 0;

}


char moji(int char_, int count)
{

	int n;
	count--;
	if( char_ == 1){
		n = count%5;
	}
	else if( char_ == 7 || char_ == 9){
		n = count%4;
	}
	else {
		n = count%3;
	}

//	if(n==0){n++;}


	return hyo[char_-1][n];
}