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<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
struct Data{
    char c;
    int n;
};
int main(void){

    int n;
    cin>>n;
    string str;
    string c[] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    while(n--){
        cin>>str;
        Data a[1200];
        char ch = 'A';
        int t = -1;
        for(int i = 0;i < str.size();i++){
            if(ch == str[i]){
                a[t].n++;
            }
            else{
                ch = str[i];
                t++;
                a[t].c = ch;
                a[t].n = 1;
            }
        }
        t++;
        for(int i = 0;i < t;i++){
            if(a[i].c == '0')continue;
            cout<<c[a[i].c - '0' - 1][(a[i].n - 1)%c[a[i].c - '0' - 1].size()];
        }
        cout<<endl;
    }


    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]%4;
	  if(g==0) g=4;
	  printf("%c",108+g);
	}
	if(prev=='7'){
	  g=a[6]%3;
	  if(g==0) g=3;
	  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=3;
	  printf("%c",118+g);
	}
	for(o=0;o<8;o++){
	  a[o]=0;
	}
      } 
      prev=v;
    }
    if(i>=2)   printf("\n");
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
char in[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 in1[9]={5,3,3,3,3,3,4,3,4};
int main(){
  int n;
  cin>>n;
  rep(j,n){
    string s;
    cin>>s;
    int i=0;
    while(i!=s.size()){
      int co=0;
      while(s[i]!='0'){
	co++;
	i++;
      }
      //cout<<co<<endl;
      if(co)cout<<in[s[i-1]-'0'-1][(co-1)%in1[s[i-1]-'0'-1]];
      i++;
    }
    cout<<endl;
  }
}

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,b=0,c=0,d=0;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;b=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 c++;
				}
				cout<<endl;
	}
	return 0;
}

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

int main(){
	
	string k[256];
	k['1']=".,!? ";
	k['2']="abc";
	k['3']="def";
	k['4']="ghi";
	k['5']="jkl";
	k['6']="mno";
	k['7']="pqrs";
	k['8']="tuv";
	k['9']="wxyz";
	k['0']="";
	
	int n;cin>>n;
	while(n--){
		string s;cin>>s;
		for(int i=0;i<s.size();i++){
			if(i==0 && s[i]=='0')continue;
			int t=-1;
			while(s[i]!='0'){
				t++;
				i++;
			}
			if(s[i-1]=='0')continue;
			cout<<k[s[i-1]][t%k[s[i-1]].size()];
		}
		cout<<endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
#define P pair<int,string>
const P m[10] = {
  P(0,""), P(5,".,!? "), P(3,"abc"), P(3,"def"), P(3,"ghi"),
  P(3,"jkl"), P(3,"mno"), P(4,"pqrs"), P(3, "tuv"), P(4,"wxyz"),
};
int main()
{
  int n;
  cin >> n;
  while(n--){
    string s;
    cin >> s;
    int p,i,j=0;
    for(i=0;i<s.length();i++){
      if(s[i] == '0' && j != 0){
	cout << (m[p].second)[(j-1)%(m[p].first)];
	j = 0;
      }else if(s[i] != '0'){
	p = s[i] - '0';
	j++;
      }
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;


int 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'};
	int n; cin >> n;
	for (int i = 0; i < n; i++){
		string str;
		cin >> str;
		if (cin.eof()) break;
		char num;
		int cnt = 0;	
		for (int i = 0; i < str.size(); i++){	
			cnt++;
			if (str[i] == '0'){
				if (str[i-1] == '1'){ 
					cout << a1[(cnt - 2)%(sizeof(a1))]  ;
				}else if (str[i-1] == '2'){
					cout << a2[(cnt - 2)%(sizeof(a2))]  ;
				}else if (str[i-1] == '3'){
					cout << a3[(cnt - 2)%(sizeof(a3))]  ;
				}else if (str[i-1] == '4'){
					cout << a4[(cnt - 2)%(sizeof(a4))]  ;
				}else if (str[i-1] == '5'){
					cout << a5[(cnt - 2)%(sizeof(a5))]  ;
				}else if (str[i-1] == '6'){
					cout << a6[(cnt - 2)%(sizeof(a6))]  ;
				}else if (str[i-1] == '7'){
					cout << a7[(cnt - 2)%(sizeof(a7))]  ;
				}else if (str[i-1] == '8'){
					cout << a8[(cnt - 2)%(sizeof(a8))]  ;
				}else if (str[i-1] == '9'){
					cout << a9[(cnt - 2)%(sizeof(a9))]  ;
				}
				cnt = 0;
			}
		}
		cout << endl;
	}
	
return 0;
}