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>
using namespace std;

int main(){
  int n;
  cin>>n;
  for(int j=0;j<n;j++){
  string s;
  cin>>s;
  char u=' ', b=0;
  char p[]={' ','.', 'a','d','g','j','m','p','t','w'};
  string t="";
  for(int i=0; i<s.size();i++) {
    int x=s[i]-'0';
    if (x==0) {
      if (b>0) {
      if (u=='.') {
        char f[]={'.',',','!','?'};
        t+=string(1, f[b-1]);
      } else {
        t+=string(1, (char)(u+b-1));
      }
      b = 0;
      }
    } else {
      u=p[x];
      b++;
      if ((x==7||x==9)&&b==5) b=1;
      if (b==4) b=1;
    }
  }
  cout<<t<<endl;
}
  return 0;
}

C++: #include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

vs a(9);

int main(){
	a[0]=".,!? ";
	a[1]="abc";
	a[2]="def";
	a[3]="ghi";
	a[4]="jkl";
	a[5]="mno";
	a[6]="pqrs";
	a[7]="tuv";
	a[8]="wxyz";
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			int id=-1,cnt=0;
			for(auto c:s){
				if(c=='0'){
					if(id>=0){
						cout<<a[id][(cnt-1)%a[id].size()];
						id=-1;
						cnt=0;
					}
				}
				else{
					id=c-'1';
					cnt++;
				}
			}
			cout<<endl;
		}
		break;
	}
}

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

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

int size[9]={5, 3, 3, 3, 3, 3, 4, 3, 4};
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 main(){
  int n;
  cin>>n;
  rep(i,n){
    string s;
    cin>>s;
    int c=0, cnt=0;
    rep(j,s.length()){
      if(s[j]=='0'){
        if(c==0)continue;
        cout<<a[c-1][(cnt-1)%size[c-1]];
        c=0; cnt=0;
      }
      else{
        c=(s[j]-'0');
        cnt++;
      }
    }
    cout<<endl;
  }
  return 0;
}

C++: #include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

using namespace std;


int main() {
	ios::sync_with_stdio(false);
	string s[10] = { "",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz" };
	cin >> N;
	for (int i = 0; i < N; i++) {
		string t;
		string ret;
		cin >> t;
		int box = 0;
		int bag = 0;
		for (auto j : t) {
			if (j == '0') {
				if (box) {
					ret += s[bag][(box - 1) % s[bag].size()];
				}
				box = 0;
			}
			else {
				if (bag == (int)(j - '0'))box++;
				else {
					bag = j - '0';
					box = 1;
				}
			}
		}
		cout << ret << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
  string code[] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
  int len[] = {5, 3, 3, 3, 3, 3, 4, 3, 4};
  
  int N;
  cin >> N;
  while(N--){
    string s;
    cin >> s;
    char c = '\0';
    int idx = 0;
    for(int i = 0; i < s.size(); i++){
      if(s[i] == '0'){
	cout << c;
	c = '\0';
	idx = 0;
      } else {
	c = code[s[i]-'0'-1][idx];
	idx = (idx + 1) % len[s[i]-'0'-1];
      }
    }
    cout << endl;
  }

  return 0;
}

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

#define pb         push_back

const int INF = 100000000;

int main(void) {
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		string in;
		cin >> in;

		bool iflag = false;
		char ch;
		int cnt = 0;
		for(int j=0; j<in.size(); j++){
			if(in[j] == '0'){
				if(ch == '-') continue;
				cout << ch;
				cnt = 0;
				ch = '-';
				iflag = false;

			}else if(in[j] == '1'){
				switch(cnt){
					case 0:
						ch = '.';
						break;
					case 1:
						ch = ',';
						break;
					case 2:
						ch = '!';
						break;
					case 3:
						ch = '?';
						break;
					case 4:
						ch = ' ';
						break;
				}
				cnt++;
				if(cnt >= 5) cnt = 0;

			}else{
				ch = 'a' + (in[j] - '2') * 3 + cnt;
				if(in[j] >= '8') ch++;
				cnt++;
				if(in[j] == '7' || in[j] == '9'){
					if(cnt >= 4) cnt = 0;
				}else if(cnt >= 3) cnt = 0;
				iflag = true;
				//cout << cnt << ":" << ch << endl;
			}
		}
		cout << endl;
	}

	
	return 0;
}

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

int main(void) {

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

    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        string s; cin >> s;
        string str = "";
        pair<char, int> num;
        num.first = ' ';
        num.second = -1;

        for (auto x : s) {
            if (x == '0') {
                if (num.first == ' ') continue;

                int bi = num.first - '0';
                str += button[bi][num.second % button[bi].size()];

                num.first = ' ';
                num.second = -1;
                continue;
            }

            num.first = x;
            num.second++;
        }

        cout << str << endl;
    }

    return 0;
}