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 <bits/stdc++.h>
using namespace std;
string s,data[9]={
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};
int n,i,p,t;
int main(){
	cin>>n;while(n--){
		cin>>s,t=1,p=s[0]-'0';
		for(i=1;i<s.length();i++){
			if(s[i]=='0'){if(p!=0)cout<<data[p-1][(t-1)%data[p-1].length()];i++,p=s[i]-'0',t=1;}else if(p==0)p=s[i]-'0';
			else t++;
		}cout<<endl;
	}
}

C++: // 2006_KeitaiMessage.cpp
//
#include <bits/stdc++.h>
using namespace std;
int n;
string m;
char d[10][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 len[10] = {-1, 5, 3, 3, 3, 3, 3, 4, 3, 4};

vector<string> split(string &str, char sep) {
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while(getline(ss, buffer, sep)) {
    if(buffer != "") v.push_back(buffer);
  }
  return v;
}

void solve() {
  vector<string> v1 = split(m, '0');
  for_each(v1.begin(), v1.end(), [](string& x) {
      int a = x[0] - '0';
      int b = x.length();
      int c = (b <= len[a] ? b - 1 : b % len[a] - 1);
      cout << d[a][c];
    });
  cout << endl;
}

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> m;
    solve();
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <queue>
using namespace std;

void p(int nu, int key){
//cout<<"dckjw"<<nu<<" "<<key<<endl;
string s[10]={"",".,!?","cab","fde","igh","ljk","omn","spqr","vtu","zwxy"};
if(key==1){
nu=nu%5;
if(nu==0) cout<<" ";
else cout<<s[1][nu-1];
}
if(key==2){
nu=nu%3;
//cout<<s[2];
cout<<s[2][nu];
}
if(key==3){
nu=nu%3;
cout<<s[3][nu];
}
if(key==4){
nu=nu%3;
cout<<s[4][nu];
}
if(key==5){
nu=nu%3;
cout<<s[5][nu];
}
if(key==6){
nu=nu%3;
cout<<s[6][nu];
}
if(key==7){
nu=nu%4;
cout<<s[7][nu];
}
if(key==8){
nu=nu%3;
cout<<s[8][nu];
}
if(key==9){
nu=nu%3;
cout<<s[9][nu];
}


}
int main(){
string s;
int n,l;
cin>>n;
for(int www=0;www<n;www++){
cin>>s;
l=s.length();
int nu=1,key;
key=s[0]-'0';


for(int j=0;j<l-1;j++){
if(s[j]!=s[j+1]){
p(nu,key);
nu=1;
key=s[j+1]-'0';
}
else{
nu++;
}

}
p(nu,key);
cout<<endl;
}
return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

char c[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'},
};

string s;

int main(){
	cin.sync_with_stdio(false);
	int cases;
	cin>>cases;
	while(cases--){
		cin>>s;
		string res;
		int i=0;
		while(1){
			while(i<s.length()&&s[i]=='0')i++;
			if(i==s.length())break;
			int cnt=0;
			while(i<s.length()&&s[i]!='0')cnt++,i++;
			int k=s[i-1]-'1';
			int r;
			if(k==0)r=5;
			else if(k==6||k==8)r=4;
			else r=3;
			res+=c[k][(cnt-1)%r];
		}
		cout<<res<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;
int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		string key[]={".,!?, ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
		string input;
		cin>>input;
		stringstream b(input);
		int num=0,count=0;
		while(){
			char c;
			if(b>>c)break;
			int input=atoi(c);
			if(input!=0){
				count++;
				num=input;
			}
			else {
				if(count!=0)
					count<<key[num-1][count%key[num-1].size()];
				num=0;count=0;
			}
		}
		cout<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

string keyd[] = {"",".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
int main(){
	int n; cin >> n;
	for(int i = 0; i < n; i++){
		string input; cin >> input;
		int pos = -1, key = 0;
		string::iterator itr = input.begin();
		while(itr != input.end()){
			if( *itr == '0'){
				if(key == 0){
					itr++;
					continue;
				}
				pos = pos % keyd[key].size();
				cout << keyd[key][pos];
				pos = -1;
				key = 0;
			}
			else{
				if(pos == -1)key = *itr - '0';
				pos++;
			}
			itr++;
		}
		cout << endl;
	}

	return 0;
}

C++: #include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;
typedef pair<int, int> P;

/** Problem2006 : Keitai Message **/
int main()
{
	string list[10] = {"#", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	int l[10] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4};
	int n;
	cin >> n;
	rep(k, n) {
		string in, ans;
		cin >> in;
		int tmp=-1; char c='#';
		rep(i, in.length()) {
			if (in[i]!='0') {
				tmp++; tmp%=l[in[i]-'0'];
				c = list[in[i]-'0'][tmp];
			} else {
				if (c != '#')
					ans+=c;
				tmp=-1;
				c='#';
			}
		}
		cout << ans << endl;
	}
}

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

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

char buf[2000];
string out;

int main() {
	int n;
	cin >> n;
	while(n--) {
		cin >> buf;
		int slen = strlen(buf);
		int i, j;
		
		for( i = 0; i < slen; i++ ) {
			char c = buf[i];
			j = -1;
			for( ; i < slen; i++ ) {
				if ( buf[i] == '0' )
					break;
				j++;
			}
			
			if ( j >= 0 )
				out += tmp[c-'0'][ j % strlen(tmp[c-'0'])];
		}
		cout << out << endl;
		out.clear();
	}
	return 0;
}