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<string>
using namespace std;
string search(int n[]) {
	if (n[0]) {
		if (n[0]%5 == 1) {
			n[0] = 0;
			return ".";
		}
		else if (n[0]%5 == 2) {
			n[0] = 0;
			return ",";
		}
		else if (n[0]%5 == 3) {
			n[0] = 0;
			return "!";
		}
		else if(n[0]%5==4) {
			n[0] = 0;
			return "?";
		}
		else {
			n[0] = 0;
			return " ";
		}
	}
	else if (n[1]) {
		if (n[1] % 3 == 1) {
			n[1] = 0;
			return "a";
		}
		else if (n[1] % 3 == 2) {
			n[1] = 0;
			return "b";
		}
		else {
			n[1] = 0;
			return "c";
		}
	}
	else if (n[2]) {
		if (n[2] % 3 == 1) {
			n[2] = 0;
			return "d";
		}
		else if (n[2] % 3 == 2) {
			n[2] = 0;
			return "e";
		}
		else {
			n[2] = 0;
			return "f";
		}
	}
	else if (n[3]) {
		if (n[3] % 3 == 1) {
			n[3] = 0;
			return "g";
		}
		else if (n[3] % 3 == 2) {
			n[3] = 0;
			return "h";
		}
		else {
			n[3] = 0;
			return "i";
		}
	}
	else if (n[4]) {
		if (n[4] % 3 == 1) {
			n[4] = 0;
			return "j";
		}
		else if (n[4] % 3 == 2) {
			n[4] = 0;
			return "k";
		}
		else {
			n[4] = 0;
			return "l";
		}
	}
	else if (n[5]) {
		if (n[5] % 3 == 1) {
			n[5] = 0;
			return "m";
		}
		else if (n[5] % 3 == 2) {
			n[5] = 0;
			return "n";
		}
		else {
			n[5] = 0;
			return "o";
		}
	}
	else if (n[6]) {
		if (n[6] % 4 == 1) {
			n[6] = 0;
			return "p";
		}
		else if (n[6] % 4 == 2) {
			n[6] = 0;
			return "q";
		}
		else if (n[6] % 4 == 3) {
			n[6] = 0;
			return "r";
		}
		else {
			n[6] = 0;
			return "s";
		}
	}
	else if (n[7]) {
		if (n[7] % 3 == 1) {
			n[7] = 0;
			return "t";
		}
		else if (n[7] % 3 == 2) {
			n[7] = 0;
			return "u";
		}
		else {
			n[7] = 0;
			return "v";
		}
	}
	else if (n[8]) {
		if (n[8] % 4 == 1) {
			n[8] = 0;
			return "w";
		}
		else if (n[8] % 4 == 2) {
			n[8] = 0;
			return "x";
		}
		else if (n[8] % 4 == 3) {
			n[8] = 0;
			return "y";
		}
		else {
			n[8] = 0;
			return "z";
		}
	}
	return "";
}


int main() {
	int i;
	cin >> i;
	string num;
	string s;
	int n[9] = {};
	for (int j = 0; j<i; j++) {
		cin >> num;
		for (int j = 0; j < num.size() ; j++) {
			switch (num[j]) {
			case '1':
				n[0]++;
				break;
			case '2':
				n[1]++;
				break;
			case '3':
				n[2]++;
				break;
			case '4':
				n[3]++;
				break;
			case '5':
				n[4]++;
				break;
			case '6':
				n[5]++;
				break;
			case '7':
				n[6]++;
				break;
			case '8':
				n[7]++;
				break;
			case '9':
				n[8]++;
				break;
			default:
					s += search(n);
			}
		}
		cout << s << endl;
		s = "";
	}
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  char m[9][5]={{'.',',','!','?',' '},
		{'a','b','c','1','1'},
		{'d','e','f','1','1'},
		{'g','h','i','1','1'},
		{'j','k','l','1','1'},
		{'m','n','o','1','1'},
		{'p','q','r','s','1'},
		{'t','u','v','1','1'},
		{'w','x','y','z','1'}};

  int a,count=0,c[100],d;
  char b[100][1024];
  cin>>a;
  for(int i=0;i<a;i++){
    scanf("%s",b[i]);
    c[i]=strlen(b[i]);
    for(int j=0;j<c[i];j++){
      if(b[i][j]!='0')count++;
      else
	if(b[i][j-1]!=0){
	  d=(int)(b[i][j-1])-48;

	  if(d==1)
	    if(count%5!=0)
	      cout<<m[d-1][count%5-1];
	    else cout<<m[d-1][4];

	  else if(d==7 || d==9)
	    if(count%4!=0)
	      cout<<m[d-1][count%4-1];
	    else cout<<m[d-1][3];

	  else
	    if(count%3!=0)
	      cout<<m[d-1][count%3-1];
	    else cout<<m[d-1][2]; 
	  count=0;
	}
    }
    cout<<endl;
  }
  return 0;
}

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

int main(int argc, char const *argv[])
{
	string a[10]={""," .,!?","cabcabcabcab","fdefdefdefde","ighighighigh"
					,"ljkljkljkljk","omnomnomnomn","spqrspqrspqr","vtuvtuvtuvtu","zwxyzwxyzwxy"};
	int n;
	cin>>n;
	while(n)
	{
		string s;
		cin>>s;
		for (int i = 0; i < s.size(); ++i)
		{
			char c=s.at(i);
			if(c=='0') continue;
			else
			{
				int b=0;
				while(s.at(i)==c) ++i,++b;
				if(c=='1') cout<<a[1].at(b%5);
				else cout<<a[c-'0'].at(b%12);
			}
		}
		cout<<endl;
		--n;
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

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

int n;
string s;

void solve(int i){
    if(!s[i]){
        return;
    }
    if(s[i] == '0'){
        solve(i + 1);
        return;
    }
    int t = s[i++];
    int c = 0;
    while(s[i] == t){
        ++i;
        ++c;
    }
    int p = t - '1';
    cout << x[p][c % x[p].size()];
    solve(i + 1);
}

int main(){
    cin >> n;
    rep(i, n){
        cin >> s;
        solve(0);
        cout << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

int main(){

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

	int N;
	string ts;
	vector<string> v;
	vector<string> ans;

	cin>>N;
	for(int i=0; i<N; i++){
		cin>>ts;
		v.push_back(ts);
	}
	for(int i=0; i<N; i++){
		bool flag = true;
		int k=-1,cnt=0;
		ans.push_back("");
		for(int j=0; j<v[i].size(); j++){
			cnt = 0;
			while(1){
				if(flag){
					flag = false;
					k = (int)(v[i][j] - '0'-1);
					cnt=-1;
				}
				if(cnt == nums[k].size()) cnt = 0;
				if(v[i][j] == '0'){
					if(k!=-1) ans[i] += nums[k][cnt];
					flag = true;
					break;
				}

				cnt++;
				j++;
			}
		}
	}

	for(int i=0; i<N; i++){
		cout<<ans[i]<<endl;
	}

	return 0;
}