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 <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1e-8

char input[1025];
char g[]=".,!? abcdefghijklmnopqrstuvwxyz";
int h[]={5,3,3,3,3,3,4,3,4};
int k[10];

inline char gc(int b, int r){
	r=(r-1)%h[b];
	return g[k[b]+r];
}

int main(){
	int t;
	cin>>t;
	k[0] = 0;
	REP(i,9)k[i+1]=k[i]+h[i];
	REP(i,t){
		cin>>input;
		int n=strlen(input);
		int r=0;
		REP(j,n){
			if(input[j]!='0')r++;
			else{
				if(r!=0)
					cout << gc(input[j-1]-'0'-1, r);
					r=0;
			
			}
		}
		cout << endl;

	}
}

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

int main(){
    char moji[][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 jo[9] = {5,3,3,3,3,3,4,3,4};

    int n; cin>>n;

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

        for(int j=0; j<s.size(); j++){ 
            if(s[j] != '0'){
                v = s[j] - '0';
                v--;
                count++;
            }

            else{
                if(count == -1) continue;
                cout<<moji[v][count % jo[v]];
                count = -1;
            }
        }

        cout<<endl;
    }

    return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
int main(void){

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

    int n; scanf("%d",&n);
    for(int i = 0;i < n;i++){
        char in[10000];
        scanf("%s",in);
        int cnt = -1;
        for(int i = 0;i < strlen(in);i++){
            if(in[i] == '0'){
                if(cnt == -1) continue;
                if(in[i-1] == '1'){
                    cnt %= 5;
                }
                else if(in[i-1] == '9'){
                    cnt %= 4;
                }
                else{
                    cnt %= 3;
                }
                printf("%c",str[in[i-1]-'0'][cnt]);
                cnt = -1;
            }
            else cnt++;
        }
        printf("\n");
    }

    return 0;
}

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


int X;
char s[1050];

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


int main(){

  cin >> X;
  while(X){

    cin >> s;

    int i = 0;
    char pre;
    int n;

    for(i = 0; i < strlen(s); i++){
      n = 1;
     
      pre = s[i];
      if(pre == '0') continue;
      while(pre == s[i+1] && i < strlen(s)){
	n++;
	i++;
      }
      int x = atoi(&pre);
   
      cout <<  b[x-1][(n-1) % b[x-1].length()];
    }
    cout << endl;
    X--;
  }
  return 0;
}

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

#define pb         push_back

const int INF = 100000000;

int main(void) {
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		string in;
		cin >> in;

		bool iflag = false;
		char ch;
		int cnt = 0;
		for(int j=0; j<in.size(); j++){
			if(in[j] == '0'){
				if(ch == '-') continue;
				cout << ch;
				cnt = 0;
				ch = '-';

			}else if(in[j] == '1'){
				switch(cnt){
					case 0:
						ch = '.';
						break;
					case 1:
						ch = ',';
						break;
					case 2:
						ch = '!';
						break;
					case 3:
						ch = '?';
						break;
					case 4:
						ch = ' ';
						break;
				}
				cnt++;
				if(cnt >= 5) cnt = 0;

			}else{
				ch = 'a' + (in[j] - '2') * 3 + cnt;
				cnt++;
				if(in[j] >= '8') ch++;
				if(in[j] == '7' || in[j] == '8'){
					if(cnt >= 4) cnt = 0;
				}else if(cnt >= 3) cnt = 0;
			}
		}
		cout << endl;
	}

	
	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
int main(void){

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

    int n; scanf("%d",&n);
    for(int i = 0;i < n;i++){
        char in[10000];
        scanf("%s",in);
        int cnt = -1;
        for(int i = 0;i < strlen(in);i++){
            if(in[i] == '0'){
                if(cnt == -1) continue;
                if(in[i-1] == '1'){
                    cnt %= 5;
                }
                else if(in[i-1] == '9' || in[i-1] == '7'){
                    cnt %= 4;
                }
                else{
                    cnt %= 3;
                }
                printf("%c",str[in[i-1]-'0'][cnt]);
                cnt = -1;
            }
            else cnt++;
        }
        printf("\n");
    }

    return 0;
}

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

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