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 <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

int pk[10];
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 main(){
    int n,curk=0;
    string s;
    cin>>n;
    for(int i=0;i<n;i++){
        string r;
        Mset(pk,0);
        cin>>s;
        for(int j=0;j<s.size();j++){
            switch(s[j]){
                case '1':
                    curk=1;
                    pk[1]++;
                    if(pk[1]>5) pk[1]=1;
                    break;
                case '2':
                    curk=2;
                    pk[2]++;
                    if(pk[2]>3) pk[2]=1;
                    break;
                case '3':
                    curk=3;
                    pk[3]++;
                    if(pk[3]>3) pk[3]=1;
                    break;
                case '4':
                    curk=4;
                    pk[4]++;
                    if(pk[4]>3) pk[4]=1;
                    break;
                case '5':
                    curk=5;
                    pk[5]++;
                    if(pk[5]>3) pk[5]=1;
                    break;
                case '6':
                    curk=6;
                    pk[6]++;
                    if(pk[6]>3) pk[6]=1;
                    break;
                case '7':
                    curk=7;
                    pk[7]++;
                    if(pk[7]>4) pk[7]=1;
                    break;
                case '8':
                    curk=8;
                    pk[8]++;
                    if(pk[8]>3) pk[8]=1;
                    break;
                case '9':
                    curk=9;
                    pk[9]++;
                    if(pk[9]>4) pk[9]=1;
                    break;
                case '0':
                    if(curk){
                        r+=D[curk][pk[curk]-1];
                        pk[curk]=0;
                        curk=0;
                    }
            }
        }
        cout<<r<<endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#include <tuple>
#include <iterator>
using namespace std;
using ll = long long;

char t[][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;
  vector<string> ans;
  for (int i = 0; i < n; ++i)
  {
    string s;
    cin >> s;
    string sum = "";
    int cnt = 0;
    char c = '0';
    for (int j = 0; j < s.size(); ++j)
    {
      if (s[j] == '0')
      {
        if (c == '0')
          continue;
        if ((c - '0') == 1)
          sum += t[c - '0'][(cnt - 1) % 5];
        else if ((c - '0') == 7 || (c - '0') == 9)
          sum += t[c - '0'][(cnt - 1) % 4];
        else
          sum += t[c - '0'][(cnt - 1) % 3];
        cnt = 0;
        c = '0';
      }
      else
      {
        c = s[j];
        cnt++;
      }
    }
    ans.push_back(sum);
  }
  for (auto &e : ans)
    cout << e << endl;

  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    int d;
    cin >> d;

    while(--d >= 0){
        string s;
        cin >> s;
        int n = s.size();

        string ret;
        int i = 0;
        while(i < n){
            char c = s[i];
            if(c == '0'){
                ++ i;
                continue;
            }

            int m = -1;
            while(i < n && c == s[i]){
                ++ m;
                ++ i;
            }
            ret += button[c-'1'][m%button[c-'1'].size()];
        }

        cout << ret << endl;
    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    vector<vector<char>> ten_key(10);
    ten_key[0] = {'\n'};
    ten_key[1] = {' ', '.', ',', '!','?'};
    ten_key[2] = {'c', 'a', 'b'};
    ten_key[3] = {'f', 'd', 'e'};
    ten_key[4] = {'i', 'g', 'h'};
    ten_key[5] = {'l', 'j', 'k'};
    ten_key[6] = {'o', 'm', 'n'};
    ten_key[7] = {'s', 'p', 'q', 'r'};
    ten_key[8] = {'v', 't', 'u'};
    ten_key[9] = {'z', 'w', 'x', 'y'};

    int N; cin >> N;
    while(N--){
        string S; cin >> S;
        string ans = "";
        int num = 0, cnt = 0;
        for(auto& c : S){
            if(c == '0' && num != 0){
                ans += ten_key[num][cnt];
                num = 0;
                cnt = 0;
            } else {
                num = int(c - '0');
                cnt = (cnt + 1) % ten_key[num].size();
            }
        }

        cout << ans << endl;
    }
}

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

#define PI 4*atan(1)
#define INF 1e8

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

vector<string> button = {".,!?",
           "abc",
           "def",
           "ghi",
           "jkl",
           "mno",
           "pqrs",
           "tuv",
           "wxyz"};


int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    int cnt = 0;
    for(int j = 0; j < s.size(); j++){
      if(s[j] == '0'){
        if(cnt != 0){
          int num = s[j-1] - '0';
          char c = button[num - 1][(cnt-1)%button[num-1].size()];
          cout << c;
          cnt = 0;
        }
      }else{
        cnt++;
      }
    }
    cout << endl;
  }
}