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 <bits/stdc++.h>
using namespace std;

typedef pair<int, int> P;

string con[15] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
int main() {
	string s;
	int n;
	cin >> n;
	for(int q = 0; q < n; ++q){
		cin >> s;
		string ans("");
		P cnt;
		cnt.first = cnt.second = 0;
		for(int i = 0; i < s.size(); ++i){
			if(s[i] == '0'){
				int num = cnt.first;
				if(num == 1){
					ans += con[num - 1][cnt.second % 5];
				}
				else if(num == 7 && num == 9){
					ans += con[num - 1][cnt.second % 4];
				}
				else if(num == 0){
					continue;
				}
				else{
					ans += con[num - 1][cnt.second % 3];
				}
				
				cnt.first = cnt.second = 0;
			}
			else{
				if(cnt.first == 0){
					cnt.first = s[i] - '0';
				}
				else{
					cnt.second++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
  string s;
  int N;
  char bot[10][20]={"0",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; 

  int count=0,flag=0;
  while(cin>>N){
    for(int i=0;i<N;i++){
      count=0;
      s.clear();
      cin>>s;
      for(int j=0;j<(int)s.size();j++){
	if(s[j]!='0'&&flag==0){
	  flag=s[j]-'0';
	}else if(flag!=0&&s[j]!='0'){
	  count++;
	}else if(s[j]=='0'&&flag!=0){
	  if(count<=strlen(bot[flag]))cout<<bot[flag][count];
	  else{
	    while(count>strlen(bot[flag])-1){
	      count=count-strlen(bot[flag]);
	    }
	    cout<<bot[flag][count];
	  }
	  count=0;
	  flag=0;
	}
      }
      cout<<endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		
		string key[]={".,!?, ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	}
	return 0;
}

C++: #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>


int main()
{
	int i,j,k;
	int n,m;
	int a[10]={0}; //押された回数
	int b[10]={0,5,3,3,3,3,3,4,3,4}; //割り算	 
	int c; //押されたボタン
	char d[5][10]={
	{'0',' ','c','f','i','l','o','s','v','z'},
	{'0','.','a','d','g','j','m','p','t','w'},
	{'0',',','b','e','h','k','n','q','u','x'},
	{'0','!','0','0','0','0','0','r','0','y'},
	{'0','?','0','0','0','0','0','0','0','0'}};
	char e[1025];
	
	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		scanf("%s",e);
		c=0;
		for(j=0;j<strlen(e);j++)
		{
			if(e[j]=='0'){
				if(c!=0)
				{
					printf("%c",d[a[c]%b[c]][c]);
					a[c]=0;
					c=0;
				}
			}else
			{
				if(e[j]=='1')c=1;
				else if(e[j]=='2')c=2;
				else if(e[j]=='3')c=3;
				else if(e[j]=='4')c=4;
				else if(e[j]=='5')c=5;
				else if(e[j]=='6')c=6;
				else if(e[j]=='7')c=7;
				else if(e[j]=='8')c=8;
				else if(e[j]=='9')c=9;
				a[c]++;
			}
		}
		printf("\n");
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0; }
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0; }

using namespace std;

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

int main(void){
	int n; cin >> n;
	while(n--) {
		string s; cin >> s;
		string res = "";
		int r=0, c=0;
		rep(i,s.size()) {
			if(s[i] == '0') {
				if(r==0) {
					c=0;
					continue;
				}
				else {
					c%=pad[r].size();
					res += pad[r][c];
					r=0, c=0;
				}
			}
			else {
				if(s[i]-'0' == r) c++;
				else r = s[i]-'0';
			}
		}
		cout << res << endl;
	}
	return 0;
}

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

int main()
{
	int n, c;
	string key[] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	string input;
	char p;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> input;
		c = 0;
		p = '0';
		for (int j = 0; j < input.size(); j++) {
			if (input[j] == '0' && p != '0') {
				cout << key[p - '0'][(c - 1) % key[p - '0'].size()] << endl;
				c = 0;
			} else if (input[j] == p) {
				c++;
			} else {
				c = 1;
			}
			p = input[j];
		}
	}
	
	return 0;
}

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

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

int main(){
  int T;
  cin >> T;
  while(T--){
    string ans = "";
    string s;
    cin >> s;
    
    int tmp;
    for(int i = 0 ; i < s.size() ;i++){
      int cnt = 0;
      tmp = s[i]-'0';
      if(tmp == 0) continue;
      while(1){
	if(s[i] != s[i+1]) break;
	cnt++, i++;
	if(button[tmp].size() == cnt) cnt = 0;
      }
      ans += button[tmp][cnt];
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <iostream>

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

int main(){
    int N;
    std::cin >> N;

    for(;N--;){
        std::string S;
        std::cin >> S;

        int key = -1, index = -1;
        std::string T = "";
        for(char c : S){
            if(c == '0'){
                if(~key){
                    T += table[key][index];
                    key = -1;
                    index = -1;
                }
            }else{
                if(!~key){
                    key = c - '0';
                    index = 0;
                }else{
                    index = (index+1) % table[key].size();
                }
            }
        }

        std::cout << T << std::endl;
    }
}

C++: #include <iostream>
#include <string>

using namespace std;

char m[][6] = {
  {},
  {5, '.', ',', '!', '?', ' '}, // 1
  {3, 'a', 'b', 'c'}, // 2
  {3, 'd', 'e', 'f'}, // 3
  {3, 'g', 'h', 'i'}, // 4
  {3, 'j', 'k', 'l'}, // 5
  {3, 'm', 'n', 'o'}, // 6
  {4, 'p', 'q', 'r', 's'}, // 7
  {3, 't', 'u', 'v'}, // 8
  {4, 'w', 'x', 'y', 'z'}, // 9
};

int main() {
  int N;
  cin >> N;

  while (N--) {
    string str;
    cin >> str;

    int s = 0, cnt = -1;
    for (int i=0; i<str.size(); i++) {
      int d = str[i] - '0';
      if (d == 0) {
        if (s != 0) { cout << m[s][ (cnt % m[s][0]) + 1 ]; }
        s = 0; cnt = -1;
      } else {
        s = d;
        cnt++;
      }
    }

    cout << endl;
  }

  return 0;
}