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;

char buf[100];
const char *data[10];

int main() {
  data[0] = "";
  data[1] = ".,!? ";
  data[2] = "abc";
  data[3] = "def";
  data[4] = "ghi";
  data[5] = "jkl";
  data[6] = "mno";
  data[7] = "pqrs";
  data[8] = "tuv";
  data[9] = "wxyz";

  int t;
  scanf("%d", &t);
  while (t--) {
    scanf(" %s", buf);
    int n = strlen(buf);
    char c = '\0';
    string res;
    int idx = 0;
    for (int i=0; i<n; i++) {
      if (buf[i] == '0') {
        if (c != '\0') {
          res += c;
          c = '\0';
        }
        idx = 0;
      } else {
        c = data[buf[i]-'0'][idx++];
        if (c == '\0') {
          c = data[buf[i]-'0'][0];
          idx = 1;
        }
      }
    }

    printf("%s\n", res.c_str());
  }
}

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

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

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;


int main(){
	
	int n;
	
	vector<char> v[10];
	
	int a[10] = {0, 0, 3, 3, 3, 3, 3, 4, 3, 4};
	
	v[1].push_back('.');
	v[1].push_back(',');
	v[1].push_back('!');
	v[1].push_back('?');
	v[1].push_back(' ');
	
	int index = 2;
	int count = 0;
	
	for(int i = 0; i < 26; i++){
		v[index].push_back('a' + i);
		count++;
		if(count >= a[index]){
			count = 0;
			index++;
		}
	}
	
	cin >> n;
	
	for(int loop = 0; loop < n; loop++){
		
		string str;
		
		cin >> str;
		
		int ref = 0;
		int count = 0;
		
		for(int i = 0; i < str.size(); i++){
			if(ref == 0 && str[i] != '0'){
				ref = str[i] - '0';
			}else if(str[i] != '0'){
				count++;
			}else if(ref != 0 && str[i] == '0'){
				printf("%c", v[ref][count % v[ref].size()]);
				ref = 0;
				count = 0;
			}
		}
		printf("\n");
		
	}
	return 0;
}

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

using namespace std;

int main(){
    string str;
    int n;
    cin >> n;
    for(int x=0;x<n;x++){
        cin >> str;
        int times = 0;
        char kind = 0;
        string ret = "";
        str += '0';
        for(int i=0;i<str.size();i++){
            if(str[i] == '0'){
                if(times != 0){
                    times--;
                    if(kind == '1'){
                        times %= 5;
                        if(times == 0){
                            ret += '.';
                        }else if(times == 1){
                            ret += ',';
                        }else if(times == 2){
                            ret += '!';
                        }else if(times == 3){
                            ret += '?';
                        }else{
                            ret += ' ';
                        }
                    }else if(kind == '2'){
                        ret += 'a' + (times%3);
                    }else if(kind == '3'){
                        ret += 'd' + (times%3);
                    }else if(kind == '4'){
                        ret += 'g' + (times%3);
                    }else if(kind == '5'){
                        ret += 'j' + (times%3);
                    }else if(kind == '6'){
                        ret += 'm' + (times%3);
                    }else if(kind == '7'){
                        ret += 'p' + (times%4);
                    }else if(kind == '8'){
                        ret += 't' + (times%3);
                    }else if(kind == '9'){
                        ret += 'w' + (times%4);
                    }
                }
                times = 0;
            }else{
                times++;
                kind = str[i];
            }
        }
        cout << ret << endl;
    }
}

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

using namespace std;

int main(){
  int n;
  cin>>n;
  cin.ignore();
  while(n--){
    string s;
    getline(cin,s);
    for(int i=0;i<s.size();i++){
      int cn=0;
      char c=s[i];
      for(;s[i]!='0';i++,cn++) ;
      if(c!='0'){
	string bc[]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	cout<<bc[c-'0'][(cn-1)%bc[c-'0'].size()];
      }
    }
    cout<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    char ans[][10] = {
        {NULL},
        {'.',',','!','?',' '},
        {'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'}
    };
    ll n; cin >> n;
    rep(i,n){
        string s(100000,0);
        cin >> s;
        int temp = 0;
        int counter =-1 ;
        for(int k = 0;k<(int)s.size();k++){
            int now = int(s[k]-48);
            if(k == 0){temp = now;counter++;}
            else if(now != 0){
                temp = now;counter++;}
            if(now == 0){
                if(temp  == 9 || temp == 7)
                    counter%=4;
                else if(temp != 1&& temp != 7 && temp!= 9)
                    counter%=3;
                else if(temp == 1)
                    counter %=5;
                cout << ans[temp][counter];
                temp = 0;counter =-1;;
            }
        }
        cout << endl;
    }
    return 0;
}