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 <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <sstream>
using namespace std;

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

vector<string> split(const string &str, const string &delim = " ") {
	int start = 0, pos;
	vector<string> result;
	
	while ( (pos = str.find_first_of( delim, start) ) != string::npos ) {
		if (pos - start != 0)
			result.push_back( str.substr( start, pos - start) );
		start = pos + 1;
	}

	return result;
}

int main(void) {
	int N;
	cin >> N;
	cin.ignore();
	for (int i = 0; i < N; i++){
		string str;
		getline(cin, str);

		vector<string> strs = split(str, "0");
		string res = "";
		for (int i = 0; i < strs.size(); i++) {
			int index1 = strs[i][0] - '0' - 1;
			int index2 = (strs[i].size() - 1) % CHAR_SET[index1].size();
			res += CHAR_SET[index1][index2];
		}

		cout << res << endl;
	}

	return 0;
}

C++: #include<stdio.h>


int main(){
	int N;

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

scanf("%d",&N);
for(int iii=0;iii<N;iii++){char x[1025]={};
scanf("%s",x);

int d=0;char pp;int y=0;
for(int i=0;i<1024;i++)
{if(x[i]!='0'&&x[i-1]==x[i]){d++;if(D[y][d]==NULL){d=0;}}
else if(x[i]!='0'&&x[i-1]!=x[i]){d=0;y=x[i]-'0';}
else if(x[i]=='0'&&y!=0){printf("%c",D[y][d]);y=0;d=0;}

}
printf("\n");
}
return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	char a[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'}};
	int n,c=0,d=0;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;d=c=0;
			for(int j=0;j<s.size();j++){
				if(s[j]=='0'&&c>0){
					if(s[j-1]=='1')d=(c-1)%5;
					else if(s[j-1]=='7'||s[j-1]=='9')d=(c-1)%4;
					else d=(c-1)%3;
					cout<<a[(int)(s[j-1]-'0')-1][d];
				c=0;
				}
				else if(s[j]=='0'&&s[j-1]=='0')continue;
				else c++;
				}
				cout<<'\n';
	}
	return 0;
}

C++: #include <cstdio>
int main(){
  int N,p,g,a[9]={};
  int i,o;
  char v,prev;
  scanf("%d",&N);
  for(i=1;i<=N+1;i++){
    p=0;
    while(1){
      p++;
      scanf("%c",&v);
      if(v=='\n') break;
      if(v=='1') a[0]++;
      if(v=='2') a[1]++;
      if(v=='3') a[2]++;
      if(v=='4') a[3]++;
      if(v=='5') a[4]++;
      if(v=='6') a[5]++;
      if(v=='7') a[6]++;
      if(v=='8') a[7]++;
      if(v=='9') a[8]++;
      if(v=='0') {
	if(prev=='1') {
	  if(a[0]%5==4) printf("?");
	  if(a[0]%5==1) printf(".");
	  if(a[0]%5==2) printf(",");
	  if(a[0]%5==3) printf("!");
	  if(a[0]%5==0) printf(" ");
	}
	if(prev=='2'){
	  g=a[1]%3;
	  if(g==0) g=3;
	  printf("%c",96+g);
	}
	if(prev=='3'){
	  g=a[2]%3;
	  if(g==0) g=3;
	  printf("%c",99+g);
	}
	if(prev=='4'){
	  g=a[3]%3;
	  if(g==0) g=3;
	  printf("%c",102+g);
	}
	if(prev=='5'){
	  g=a[4]%3;
	  if(g==0) g=3;
	  printf("%c",105+g);
	}
	if(prev=='6'){
	  g=a[5]%3;
	  if(g==0) g=3;
	  printf("%c",108+g);
	}
	if(prev=='7'){
	  g=a[6]%4;
	  if(g==0) g=4;
	  printf("%c",111+g);
	}
	if(prev=='8'){
	  g=a[7]%3;
	  if(g==0) g=3;
	  printf("%c",115+g);
	}
	if(prev=='9'){
	  g=a[8]%4;
	  if(g==0) g=4;
	  printf("%c",118+g);
	}
	for(o=0;o<8;o++){
	  a[o]=0;
	}
      } 
      prev=v;
    }
    if(i>=2)   printf("\n");
  }
  return 0;
}

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

#define itn long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)(n);i>=0;--i)
#define debug(x) cout << #x << "=" << (x) << endl;
const ll MOD=1e9+7;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
  int N;
  cin>>N;
  string c=".,!? ";
  string al="pqrstuvwxyz";
  rep(i,N){
    string s;
    cin>>s;
    int ct=0;
    for(int i=0;i<s.size();i++)
      if(s[i]=='0'){
        if(ct==0)continue;ct--;
        int l=s[i-1]-'1';
        if(!l)cout<<c[ct%5];
        else if(l==6)
          cout<<al[ct%4];
        else if(l==7)
          cout<<al[4+ct%3];
        else if(l==8)
          cout<<al[7+ct%4];
        else cout<<(char)(--l*3+ct%3+'a');ct=0;
      }else ct++;
    cout<<endl;
  }
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  solve();
  return 0;
}

C++: 
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

string A = ".,!?_",B="abc",C="def",D="ghi",E="jkl",F="mno",G="pqrs",H="tuv",I="wxyz";


int main(){
    int n;
    cin >> n;
    rep(w,n){
        string S;
        cin >> S;
        string ans="";
        int i=0;
        while (i<S.length()) {
            char ch = S[i];
            if(ch=='0'){
                i++;
                continue;
            }
            int t=0;
            while (S[i]!='0' and i<S.length()){
                i++;
                t++;
            }
            if(ch=='1'){
                        int flag = (t-1)%5;
                        if(flag == 4){
                            ans += " ";
                        }else{
                            ans += A[flag];
                        }
                    }
            if(ch=='2'){
                int flag = (t-1)%3;
                ans += B[flag];
            }
            if(ch=='3'){
                int flag = (t-1)%3;
                ans += C[flag];
            }
            if(ch=='4'){
                int flag = (t-1)%3;
                ans += D[flag];
            }
            if(ch=='5'){
                int flag = (t-1)%3;
                ans += E[flag];
            }
            if(ch=='6'){
                int flag = (t-1)%3;
                ans += F[flag];
            }
            if(ch=='7'){
                int flag = (t-1)%4;
                ans += G[flag];
            }
            if(ch=='8'){
                int flag = (t-1)%3;
                ans += H[flag];
            }
            if(ch=='9'){
                int flag = (t-1)%4;
                ans += I[flag];
            }
            i++;
        }
        cout << ans << endl;
    }
}