Go: /*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2006&lang=jp
Keitai Message
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

// 標準入力を取得するScannerのインスタンスを作成
var scanner = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込みstringとして返す
func readLine() string {
	if scanner.Scan() {
		return scanner.Text()
	}
	return ""
}

func main() {
	// 1: . , ! ? (スペース)
	// 2: a b c
	// 3: d e f
	// 4: g h i
	// 5: j k l
	// 6: m n o
	// 7: p q r s
	// 8: t u v
	// 9: w x y z
	// 0: 確定ボタン

	// 改行から空白区切りに変更
	scanner.Split(bufio.ScanWords)
	line, _ := strconv.Atoi(readLine()) // 5行標準入力が続く

	table := []string{
		"",      // 0 index調整ためダミーデータ
		".,!? ", // 1
		"abc",   // 2
		"def",   // 3
		"ghi",   // 4
		"jkl",   // 5
		"mno",   // 6
		"pqrs",  // 7
		"tuv",   // 8
		"wxyz"}  // 9

	// 5行分の標準入力を格納するsliceを作成する
	messages := make([]string, 0, line)

	// sliceに標準入力の内容を格納する
	for i := 0; i < line; i++ {
		messages = append(messages, readLine()) // messages=[20 220 222220 44033055505550666011011111090666077705550301110 000555555550000330000444000080000200004440000]
	}

	// 各行毎に解析する
	for _, message := range messages { // message=000555555550000330000444000080000200004440000
		// 0で分割する
		messageSlice := strings.Split(message, "0") // messageSlice=[   55555555    33    444    8    2    444    ]
		for _, word := range messageSlice {
			if word == "" {
				// NOP.
				// 0をセパレーターにしているので空文字がsliceに格納されてい箇所がある
				// 何もしない
			} else { // word=55555555
				// 一文字取り出しコード値をASCII文字に変換する
				ascii := string((word[0])) // word[0]=5

				// ASCII文字からintへ変換する(tableのindexになる)
				number, _ := strconv.Atoi(ascii)

				// 入力回数をカウントする
				count := len(word) // 5

				// 同じ数字を続けて入力すると変化する文字はループすることを考慮する
				for count > len(table[number]) { // 5 > 3
					count -= len(table[number]) // 2
				}

				// キー配列
				keys := table[number]                   //jkl
				fmt.Printf("%s", string(keys[count-1])) //k
			}
		}
		fmt.Println() // 改行
	}
}

C++: #include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int count(int y, int m, int d){
    int res = 0;
    res += d;
    res += (m-1) * 19;
    if(y%3){
        res += m / 2;
    }else{
        res += m - 1;
    }
    --y;
    res += y * 195;
    res += y / 3 * 5;
    return res;
}

string func(){
    string str;
    string codes[]={"*", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    cin >> str;
    int count=0;
    int bn=0;
    string res="";
    foreach(i, str){
        int j = i-'0';
        if(j==bn)++count;
        else{
            res += codes[bn][count%codes[bn].size()];
            bn=j;
            count=0;
        }
    }
    string ans = "";
    foreach(i, res){
        if(i!='*')ans+=i;
    }
    return ans;
}

int main(){
    int N;
    cin >> N;
    REP(i, N){
        cout << func() << endl;
    }
    return 0;
}

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

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

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

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
string order;
vector<int> num;
vector<char> word;
int n;
char button[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 but = 0,push = 0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> order;
    for(int j=0;j<order.size();j++){
      num.push_back((int)(order[j]-'0'));
    }
    for(int j=0;j<num.size();j++){
      if(1<=num[j] && num[j]<=9 && but==0){
	but = num[j];
      }else if(1<=num[j] && num[j]<=9 && but!=0){
	push++; //cout << "pushed" << endl;
      }else if(num[j]==0 && but && but!=1 && but!=7 && but!=9){
	word.push_back(button[but-1][push%3]); //cout << button[but-1][push%3] << endl;
	push = 0;
	but = 0;
      }else if(num[j]==0 && but && (but==7 || but==9)){
	word.push_back(button[but-1][push%4]); //cout << button[but-1][push%4] << endl;
	push = 0;
	but = 0;
      }else if(num[j]==0 && but && but==1){
	word.push_back(button[but-1][push%5]); //cout << button[but-1][push%4] << endl;
	push = 0;
	but = 0;
      }else if(num[j]==0 && !but){
	continue;
      }
    }
    for(int k=0;k<word.size();k++){
      cout << word[k];
    }
    cout << endl;
    word.clear();
    num.clear();
  }
  
  return 0;
  
}

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

int main(){
	int n;
	for(cin >> n; n--; ){
		string s;
		cin >> s;
		s += '0';

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

		int d = 0, t = 0;
		for(size_t i = 0; i < s.size(); ++i){
			int c = s[i] - '0';
			if(c == 0 || c != d){
				if(d != 0){
					cout << tbl[d][t];
				}
				d = c;
				t = 0;
			}
			else{
				t = (t + 1) % tbl[d].size();
			}
		}
		cout << endl;
	}
}

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

int main(){
  char l[10][6]={{}, {".,!? "}, {"abc"}, {"def"}, {"ghi"}, {"jkl"}, {"mno"}, {"pqrs"}, {"tuv"}, {"wxyz"}};
  //char **l={{}, {".,!? "}, {"abc"}, {"def"}, {"ghi"}, {"jkl"}, {"mno"}, {"pqrs"}, {"tuv"}, {"wxyz"}};
  int n;
  cin >> n;
  for(int k=0;k<n;k++){
    char c[1025];
    cin >> c;
    int size=0;
    for(int i=0;i<1025;i++){
      if(c[i]=='\0'||c[i]=='\n'){
        break;
      }
      size++;
    }

    int count=0;
    for(int i=0;i<size;i++){
      if(c[i]=='0'){
        if(i!=0){
          int num = (int)(c[i-1]-'0');
          int s=0;
          for(int j=0;j<7;j++){
            if(l[num][j]=='\0'){
              s=j;
              break;
            }
          }
          if(c[i]!=c[i-1])
            cout << l[num][(count-1)%s];
          count=0;
        }
      }else{
        count++;
      }
    }


    /*for(int i=1;i<size;i++){
      if(c[i-1]=='0'&&c[i]=='0') continue;
      else if(c[i-1]!='0'&&(c[i-1]==c[i]||c[i]!='0')){
      count++;
      }else if(c[i]=='0'){
      int s=0;
      int num = (int)(c[i-1]-'0');
      if(num==0) continue;
      for(int j=0;j<7;j++){
      if(l[num][j]=='\0'){
      s=j+1;
      break;
      }
      }
    //int num = static_const<int>(c[i-1]);
    if(s!=0)cout << l[num][count%s];
    count=0;
    }
    if(i==size-1) cout << endl;
    }*/

    cout << endl;
    for(int i=0;i<1025;i++){
      c[i]='\0';
    }
  }
  return 0;
}