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 <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

string solve(string s){
    int count=0;
    string ans;
    char keep;
    string keeps;
    char c='0';
    for(int i=0;i<s.size();i++){
        // char k=s[i];
        if(s[i]!='0'){
            count++;
            c=s[i];
        }
        else{
            if(count!=0){
                if(c== '2'){
                    if(count%3==1)ans.append(1,'a');
                    else if(count%3==2)ans.append(1,'b');
                    else ans.append(1,'c');
                }
                else if(c== '3'){
                    if(count%3==1)ans.append(1,'d');
                    else if(count%3==2)ans.append(1,'e');
                    else ans.append(1,'f');
                }
                else if(c== '4'){
                    if(count%3==1)ans.append(1,'g');
                    else if(count%3==2)ans.append(1,'h');
                    else ans.append(1,'i');
                }
                else if(c== '5'){
                    if(count%3==1)ans.append(1,'j');
                    else if(count%3==2)ans.append(1,'k');
                    else ans.append(1,'l');
                }
                else if(c== '6'){
                    if(count%3==1)ans.append(1,'m');
                    else if(count%3==2)ans.append(1,'n');
                    else ans.append(1,'o');
                }
                else if(c== '7'){
                    if(count%4==1)ans.append(1,'p');
                    else if(count%4==2)ans.append(1,'q');
                    else if(count%4==3)ans.append(1,'r');
                    else ans.append(1,'s');
                }
                else if(c== '8'){
                    if(count%3==1)ans.append(1,'t');
                    else if(count%3==2)ans.append(1,'u');
                    else ans.append(1,'v');
                }
                else if(c== '9'){
                    if(count%4==1)ans.append(1,'w');
                    else if(count%4==2)ans.append(1,'x');
                    else if(count%4==3)ans.append(1,'y');
                    else ans.append(1,'z');
                }
                else if(c== '1'){
                    if(count%5==1)ans.append(1,'.');
                    else if(count%5==2)ans.append(1,',');
                    else if(count%5==3)ans.append(1,'!');
                    else if(count%5==4)ans.append(1,'?');
                    else ans.append(1,' ');
                }
                count=0;
            }
        }
    }
    // cout << ans << "%%%%%%%%%%%%%%%%"<<endl;
    return ans;
}

int main(int argc, char const *argv[]) {
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    vector<string>ans;
    for(int i=0;i<n;i++){
        cin >> s;
        ans.push_back(solve(s));
    }
    for(int i=0;i<n;i++){
        cout << ans[i]<<endl;
    }
}

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

int main()
{
  int n,i,j;
  string s;
  char c[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'}
  };
  cin>>n;
  while(cin>>s){
    j=0;
    for(i=0;i<s.size();i++){
      if(s[i]!='0'){
	j++;
      }else{
	if(j)cout<<c[s[i-1]-'0'][(j-1)%(3+2*(s[i-1]=='1')+(s[i-1]=='7')+(s[i-1]=='9'))];
	j=0;
      }
    }
    cout<<endl;
  }
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;


int main() {
	vector<string> dig = { ".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz" };
	vector<int> cn = { 5,3,3,3,3,3,4,3,4 };
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	REP(j, n) {
		string s;
		cin >> s;

		int i = 0;
		while (i < s.size()) {
			char c = s[i];
			++i;
			if (c != '0') {
				int cnt = 0;
				while (s[i] == c) {
					cnt++;
					++i;
				}
				cout << dig[int(c - '0') - 1][cnt%cn[int(c - '0') - 1]];
			}
		}
		cout << endl;
	}
	
	return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<string>

using namespace std;

int main(){
	string str;
	char last;
	char key[10][13]={
		{' '},
		{' ','.',',','!','?',' '},
		{' ','a','b','c','a','b','c','a','b','c','a','b','c'},
		{' ','d','e','f','d','e','f','d','e','f','d','e','f'},
		{' ','g','h','i','g','h','i','g','h','i','g','h','i'},
		{' ','j','k','l','j','k','l','j','k','l','j','k','l'},				
		{' ','m','n','o','m','n','o','m','n','o','m','n','o'},
		{' ','p','q','r','s','p','q','r','s','p','q','r','s'},
		{' ','t','u','v','t','u','v','t','u','v','t','u','v'},
		{' ','w','x','y','z','w','x','y','z','w','x','y','z'},								
	};
	cin >> str;
	int array[10],i;
	for(i=0;i<10;i++){
		array[i]=0;
	}
	last = str[0];
	for(i=0;i<str.size();i++){
		array[str[i]-0x30]++;
		if(array[str[i]-0x30] > 12 && last!=1) array[str[i]-0x30]=1;
		if(array[1] > 5) array[1]=1;
		if(str[i]=='0' && last!='0'){
			// cout << last << ':' << array[last-0x30] << endl;
			cout <<  key[(last-0x30)][array[last-0x30]];
			for(int l=0;l<10;l++){
				array[l]=0;
			}
		}
		last = str[i];
	}
	if(last=='0')
		cout << endl;
	return 0;
}

C++: #include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  char str[1025]={};
  char moji[10][6]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  int i;
  int n;

  cin>>n;
  rep(i,n){
    cin>>str;
    int len=strlen(str);
    int j=0;
    while(j<len){
      int num=0;
      while(str[j]!='0'){
	j++;
	num++;
      }
      if(j==0){
	j++;
	continue;
      }
      int a=str[j-1]-'0';
      if(a==1)
	cout<<moji[a][(num-1)%5];
      else if((a>1 && a<7)|| a==8)
	cout<<moji[a][(num-1)%3];
      else
	cout<<moji[a][(num-1)%4];
      j++;
    }
    cout<<endl;
  }
}