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<algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,(n))

char in[1029];
char out[78];

void input(){
  cin >>in;
  cout<<in[1];
}

void solve(){ 
  int count=0;
  int  c=1;
  char p='\0';
  REP(i,78)out[i]=' ';
  for(int i=0;in[i]!='\0';i++){
    switch(in[i]){
      case '1':if(p=='1')c++;
      else p='1';
      break;

      case '2':if(p=='2')c++;
      else p='2';
      break;

      case '3':if(p=='3')c++;
      else p='3';
      break;
            
      case '4':if(p=='4')c++;
      else p='4';
      break;

      case '5':if(p=='5')c++;
      else p='5';
      break;

      case '6':if(p=='6')c++;
      else p='6';
      break;

      case '7':if(p=='7')c++;
      else p='7';
      break;

      case '8':if(p=='8')c++;
      else p='8';
      break;

      case '9':if(p=='9')c++;
      else p='9';
      break;

      case '0':
      if(p=='1'){
        if(c%4==1)out[count]='.';
        else if(c%4==2)out[count]=',';
        else if(c%4==3)out[count]='!';
        else out[count]='?';

      }

      if(p=='2'){
        if(c%3==1)out[count]='a';
        else if(c%3==2)out[count]='b';
        else out[count]='c';
        }

      if(p=='3'){
        if(c%3==1)out[count]='d';
        else if(c%3==2)out[count]='e';
        else out[count]='f';
      }

      if(p=='4'){
        if(c%3==1)out[count]='g';
        else if(c%3==2)out[count]='h';
        else out[count]='i';
      }

      if(p=='5'){
        if(c%3==1)out[count]='j';
        else if(c%3==2)out[count]='k';
        else out[count]='l';
      }

      if(p=='6'){
        if(c%3==1)out[count]='m';
        else if(c%3==2)out[count]='n';
        else out[count]='o';
      }

      if(p=='7'){
        if(c%4==1)out[count]='p';
        else if(c%4==2)out[count]='q';
        else if(c%4==3)out[count]='r';
        else out[count]='s';
      }

      if(p=='8'){
        if(c%3==1)out[count]='t';
        else if(c%3==2)out[count]='u';
        else out[count]='v';
      }

      if(p=='9'){
        if(c%4==1)out[count]='w';
        else if(c%4==2)out[count]='x';
        else if(c%4==3)out[count]='y';
        else out[count]='z';
      }
      if (p!='\0') count++;
      p='\0';
      c=1;
    }
    out[count]='\0';
   }
   for(int i;out[i]!='\0';i++)cout<<out[i];
   cout<<endl;
}

int main(){
  int n;
  cin>>n;
  REP(i,n){
    input();
    solve();
  }
}

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

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

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

using namespace std;

int main(int argc, char const *argv[])
{
	char k[9][5]={{'.',',','!','?',' '},
					{'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'}};
	//0,6,8

	string s,out;
	int n;

	cin>>n;

	for(int i1=0;i1<n;i1++){
		cin>>s;
		out="";
		vector<int> v;
		for(int i2=0;i2<s.size();i2++){
			if(s[i2]=='0'){
				if(v.empty()){}
				else {
					if(v.back()==1){
						out+=k[v.back()-1][(v.size()-1)%5];
					}
					else if (v.back()==7 || v.back()==9){
						out+=k[v.back()-1][(v.size()-1)%4];
					}
					else{
						out+=k[v.back()-1][(v.size()-1)%3];
					}
					
				}
				v.clear();
			}
			else {
				if(!v.empty() && v.back()==s[i2]-48){
					v.push_back(s[i2]-48);
				}
				else {
					v.clear();
					v.push_back(s[i2]-48);
				}

			}
		}
		cout<<out<<endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#define R return

using namespace std;

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

int main()
{
    int n, c, p;
    string s, ans;
    cin>>n;
    for (int i=0; i<n; i++)
    {
        ans=""; c=0; p=0;
        cin>>s;
        for (int j=0; j<s.size(); j++)
        {
            if (s[j]=='0' && p!=0) { ans+=convert(c, p); c=0; p=0; }
            else if (s[j]==p) { c++; }
            else { p=s[j]-48; c++; }
        }
        cout<<ans<<'\n';
    }
    R 0;
}

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

typedef pair<int, int> P;

string con[15] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
int main() {
	string s;
	int n;
	cin >> n;
	for(int q = 0; q < n; ++q){
		cin >> s;
		string ans("");
		P cnt;
		cnt.first = cnt.second = 0;
		for(int i = 0; i < s.size(); ++i){
			if(s[i] == '0'){
				int num = cnt.first;
				if(num == 1){
					ans += con[num - 1][cnt.second % 5];
				}
				else if(num == 7 || num == 9){
					ans += con[num - 1][cnt.second % 4];
				}
				else if(num == 0){
					continue;
				}
				else{
					ans += con[num - 1][cnt.second % 3];
				}
				
				cnt.first = cnt.second = 0;
			}
			else{
				if(cnt.first == 0){
					cnt.first = s[i] - '0';
				}
				else{
					cnt.second++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}