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 <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;
        for(int j=1;j<str.size();j++){
           if(str[j]=='0' && str[j-1]!='0'){
                if(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{
               cou++;
           }
        }
        cout << endl;
    }
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[1080], b[1080];
int n, m;

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

char _str[10800];
void output(int val, int cnt){
	if(val == 0)return;
	cout << button[val][(cnt-1) % button[val].size()];
}


int main(){
	int q;
	cin >> q;
	while(q--){
		cin >> str;
		int val = 0;
		int cnt = 0;
		for(int i = 0;i < str.size();i++){
			if(str[i] == '0'){
				output(val, cnt);
				val = cnt = 0;
			}
			else{
				val = str[i] - '0';
				cnt++;
			}
		}
		output(val, cnt);
		cout << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  string in;
  char list[9][6]={
    {'.',',','!','?',' ','/'},
    {'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 x=-1,y=-1;
  
  cin >>N;
  
  for(int i=0 ; i < N ; i++){
    
    cin >>in;
    
    for(int j=0 ; j < (int)in.size() ; j++){
      
      char in_one=in[j];
      int num=atoi(&in_one);

      if(num == 0){
	if(y != -1)cout <<list[y][x];
	y=-1;
	x=-1;
      }else{
	x++;
	if(list[y][x] == '/')x=0;
	y=num-1;
      }
      
    }
    cout <<endl;
    
  }
  
  return 0;
}

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

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  string s[9];
  s[0]=".,!?S";
  s[1]="abc";
  s[2]="def";
  s[3]="ghi";
  s[4]="jkl";
  s[5]="mno";
  s[6]="pqrs";
  s[7]="tuv";
  s[8]="wxyz";
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string t;
    cin>>t;
    int c=0;
    for(int j=0;j<t.size();j++){
      if(t[j]=='0'){
	if(j-1>=0)if(t[j-1]!='0'){
	  if(s[t[j-1]-'1'][(j-c-1)%s[t[j-1]-'1'].size()]=='S')cout<<" ";
	  else cout<<s[t[j-1]-'1'][(j-c-1)%s[t[j-1]-'1'].size()];
	}
	c=j+1;
      }
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

char moji(char t,int cnt){
  if(t=='1'){
    cnt%=5;
    if(cnt==1) return '.';
    if(cnt==2) return ',';
    if(cnt==3) return '!';
    if(cnt==4) return '?';
    return ' ';
  }
  if(t=='2'){
    cnt%=3;
    if(cnt==1) return 'a';
    if(cnt==2) return 'b';
    return 'c';
  }
  if(t=='3'){
    cnt%=3;
    if(cnt==1) return 'd';
    if(cnt==2) return 'e';
    return 'f';
  }
  if(t=='4'){
    cnt%=3;
    if(cnt==1) return 'g';
    if(cnt==2) return 'h';
    return 'i';
  }
  if(t=='5'){
    cnt%=3;
    if(cnt==1) return 'j';
    if(cnt==2) return 'k';
    return 'l';
  }
  if(t=='6'){
    cnt%=3;
    if(cnt==1) return 'm';
    if(cnt==2) return 'n';
    return 'o';
  }
  if(t=='7'){
    cnt%=4;
    if(cnt==1) return 'p';
    if(cnt==2) return 'q';
    if(cnt==3) return 'r';
    return 's';
  }
  if(t=='8'){
    cnt%=3;
    if(cnt==1) return 't';
    if(cnt==2) return 'u';
    return 'v';
  }
  if(t=='9'){
    cnt%=4;
    if(cnt==1) return 'w';
    if(cnt==2) return 'x';
    if(cnt==3) return 'y';
    return 'z';
  }
}

int main() {
  int n; cin >> n;
  string s;
  for(int i=0;i<n;++i) {
    cin >> s;
    int cnt=0;
    char t;
    for(int j=0;j<s.size();++j){
      if(s[j]=='0' && cnt) {
	cout << moji(t,cnt);
	cnt=0;
      } else if(s[j]!='0') t=s[j],cnt++;
    }
    cout << endl;
  }
  
  return 0;
}

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

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

C++: // Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  string m[] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    int cnt = 0, btn = S[0];
    for (int j = 1; j < S.length(); j++) {
      if (S[j] == '0') {
        if (btn != '0') {
          cout << m[btn-'0'-1][cnt%m[btn-'0'-1].length()];
        }
        if (j != S.length()-1) {
          btn = S[j+1];
        }
        cnt = -1;
      } else {
        if (btn != S[j]) {
          btn = S[j];
          cnt = -1;
        }
        cnt++;
      }
    }
    cout<<endl;
  }
}