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 <stdio.h>

int main(){
    int m,i,j,k,x[77],p,q,r;
    char str[1024];
    scanf("%d",&m);
    for (k=0;k<m;k++){
        scanf("%s",str);
        i=0;
        j=1;
        while(1){
            if (str[i]=='\n') break;
            if (str[i]==0) {
                if (i>0&&str[i-1]!=0){
                    x[j]=i;
                    j++;
                }
            }
            i++;
            
        }
        x[0]=0;
        for (i=0;i<=j;i++) {
            p=x[i+1]-x[i]-1;
            q=p%3;
            r=p%4;
            if (str[x[i]+1]==1) {
                if (r==0) printf("?");
                if (r==1) printf(".");
                if (r==2) printf(",");
                if (r==3) printf("!");
            }
            if (str[x[i]+1]==2) {
                if (q==1) printf("a");
                if (q==2) printf("b");
                if (q==0) printf("c");
            }
            if (str[x[i]+1]==3) {
                if (q==1) printf("d");
                if (q==2) printf("e");
                if (q==0) printf("f");
            }
            if (str[x[i]+1]==4) {
                if (q==1) printf("g");
                if (q==2) printf("h");
                if (q==0) printf("i");
            }
            if (str[x[i]+1]==5) {
                if (q==1) printf("j");
                if (q==2) printf("k");
                if (q==0) printf("l");
            }
            if (str[x[i]+1]==6) {
                if (q==1) printf("m");
                if (q==2) printf("n");
                if (q==0) printf("o");
            }
            if (str[x[i]+1]==7) {
                if (r==1) printf("p");
                if (r==2) printf("q");
                if (r==3) printf("r");
                if (r==0) printf("s");
            }
            if (str[x[i]+1]==8) {
                if (q==1) printf("t");
                if (q==2) printf("u");
                if (q==0) printf("v");
            }
            if (str[x[i]+1]==9) {
                if (r==1) printf("w");
                if (r==2) printf("x");
                if (r==3) printf("y");
                if (r==0) printf("z");
            }
            
        
        }
    }
    return 0;
    
}

C++: #include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  /*
  char a1[5] = {'.',',','!','?',' '};
  char a2[3] = {'a','b','c'};
  char a3[3] = {'d','e','f'};
  char a4[3] = {'g','h','i'};
  char a5[3] = {'j','k','l'};
  char a6[3] = {'m','n','o'};
  char a7[4] = {'p','q','r','s'};
  char a8[3] = {'t','u','v'};
  char a9[4] = {'w','x','y','z'};
  */
  /*
  string a1=".,!? ";
  string a2="abc";
  string a3="def";
  string a4="ghi";
  string a5="jkl";
  string a6="mno";
  string a7="pqrs";
  string a8="tuv";
  string a9="wxyz";
 */
 string a[9] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
 //for(int i=0; i<9; i++) cout << a[i] << " ";
 int n;
 cin >> n;
 for(int k=0; k<n; k++){
   string s;
   cin >> s;
   for(int i=0; i<(int)s.size(); i++){
     char c = s[i];
     int count = 0;
     for(i=i+1; i<(int)s.size(); i++){
       if(s[i] != c) break; //先頭と違っていたら
       count++;
    }
    i--; //?
    if(c=='0') continue;
    int num = c-'0'-1; //何故'0'?
    //cout << "#" << num << " " << c << " ";
    int tmp = count % a[num].size();
    cout << a[num][tmp];
    }
    cout << endl;
 }
 return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    char ans[][10] = {
        {'\0'},
        {'.',',','!','?',' '},
        {'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'}
    };
    ll n; cin >> n;
    rep(i,n){
        string s(100000,0);
        cin >> s;
        int temp = 0;
        int counter =-1 ;
        for(int k = 0;k<(int)s.size();k++){
            int now = int(s[k]-48);
            if(k == 0){temp = now;counter++;}
            else if(now != 0){
                temp = now;counter++;}
            if(now == 0){
                if(temp  == 9 || temp == 7)
                    counter%=4;
                else if(temp != 1&& temp != 7 && temp!= 9)
                    counter%=3;
                else if(temp == 1)
                    counter %=5;
                cout << ans[temp][counter];
                temp = 0;counter =-1;;
            }
        }
        cout << endl;
    }
    return 0;
}