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 <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
using namespace std;
int n;

int main() {
    cin >> n;
    for(int i=0; i<n; ++i){
        string str; cin >> str;
        int N = str.size();
        for(int i=0; i<N; ++i){
            if(str[i]=='1'){
                int pos = i, cnt=0;
                while(str[pos]!='0'){
                    pos++; cnt++;
                }
                i = pos;
                if(cnt%5==1) cout << ".";
                else if(cnt%5==2) cout << ",";
                else if(cnt%5==3) cout << "!";
                else if(cnt%5==4) cout << "?";
                else if(cnt%5==0) cout << " ";
            }else if(str[i]=='2'){
                int pos = i, cnt=0;
                while(str[pos]!='0'){
                    pos++; cnt++;
                }
                i = pos;
                if(cnt%3==1) cout << "a";
                else if(cnt%3==2) cout << "b";
                else if(cnt%3==0) cout << "c";
            }else if(str[i]=='3'){
                int pos = i, cnt=0;
                while(str[pos]!='0'){
                    pos++; cnt++;
                }
                i = pos;
                if(cnt%3==1) cout << "d";
                else if(cnt%3==2) cout << "e";
                else if(cnt%3==0) cout << "f";
            }else if(str[i]=='4'){
                int pos = i, cnt=0;
                while(str[pos]!='0'){
                    pos++; cnt++;
                }
                i = pos;
                if(cnt%3==1) cout << "g";
                else if(cnt%3==2) cout << "h";
                else if(cnt%3==0) cout << "i";
            }else if(str[i]=='5'){
                int pos = i, cnt=0;
                while(str[pos]!='0'){
                    pos++; cnt++;
                }
                i = pos;
                if(cnt%3==1) cout << "j";
                else if(cnt%3==2) cout << "k";
                else if(cnt%3==0) cout << "l";
            }else if(str[i]=='6'){
                int pos = i, cnt=0;
                while(str[pos]!='0'){
                    pos++; cnt++;
                }
                i = pos;
                if(cnt%3==1) cout << "m";
                else if(cnt%3==2) cout << "n";
                else if(cnt%3==0) cout << "o";
            }else if(str[i]=='7'){
                int pos = i, cnt=0;
                while(str[pos]!='0'){
                    pos++; cnt++;
                }
                i = pos;
                if(cnt%4==1) cout << "p";
                else if(cnt%4==2) cout << "q";
                else if(cnt%4==3) cout << "r";
                else if(cnt%4==0) cout << "s";
            }else if(str[i]=='8'){
                int pos = i, cnt=0;
                while(str[pos]!='0'){
                    pos++; cnt++;
                }
                i = pos;
                if(cnt%3==1) cout << "t";
                else if(cnt%3==2) cout << "u";
                else if(cnt%3==0) cout << "v";
            }else if(str[i]=='9'){
                int pos = i, cnt=0;
                while(str[pos]!='0'){
                    pos++; cnt++;
                }
                i = pos;
                if(cnt%4==1) cout << "w";
                else if(cnt%4==2) cout << "x";
                else if(cnt%4==3) cout << "y";
                else if(cnt%4==0) cout << "z";
            }
        }
        cout << endl;
    }    
    return 0;
}

C++: #include<iostream>
#include<string>
#include<cstring>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
using namespace std;

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

int main(){
	string s,alt;
	int n;
	cin>>n;
	rep(a,n){
		cin>>s;
		alt="";
		vector<string> vec;
		rep(i,s.size()){
			if(s[i]=='0'){
				if(alt=="")continue;
				else vec.pb(alt);alt="";
			}else alt+=s[i];
		}
		string ans="";
		rep(i,vec.size()){
			int num=vec[i][0]-'0';
			ans+=moji[num-1][(vec[i].size()-1)%moji[num-1].size()];
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> duo;

#define TT template<typename T>
TT T    sq(T x){ return x*x; }
TT int  ubnd(vector<T>& v,T x){ return upper_bound(v.begin(), v.end(), x) - v.begin(); }
TT int  lbnd(vector<T>& v,T x){ return lower_bound(v.begin(), v.end(), x) - v.begin(); }
TT void sort(T& v){ sort(v.begin(), v.end()); }
TT void revs(T& v){ reverse(v.begin(), v.end()); }
TT void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TT void show(T& v,char d=' ',char e='\n'){for(int i=0;i<v.size();++i)cout<<v[i]<<((i==v.size()-1)?e:d);}
TT void inpt(vector<T>& v,int n){ v.reserve(n);for(int i=0;i<n;++i){T x; cin>>x; v.push_back(x);} }
TT T In(){ T x; cin >> x; return x; }

static inline void fast_io(){ ios::sync_with_stdio(0); cin.tie(0); }
static inline int in(){ int x; scanf("%d", &x); return x; }
static inline string instr(){ string x; cin >> x; return x; }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};

vector<string> split(const string& s, char d)
{
  stringstream ss(s);
  vector<string> vs;
  string token;
  while (getline(ss, token, d)) vs.push_back(token);
  return vs;
}

int main()
{
  fast_io();
  vector<string> table;
  table.push_back(".,!? ");
  table.push_back("abc");
  table.push_back("def");
  table.push_back("ghi");
  table.push_back("jkl");
  table.push_back("mno");
  table.push_back("pqrs");
  table.push_back("tuv");
  table.push_back("wxyz");

  int n;
  cin >> n;
  for (int i = 0; i < n; i++){
    string s;
    cin >> s;
    vector<string> vs = split(s, '0');
    for (int j = 0; j < vs.size(); j++){
      if (!vs[j].size()) continue;
      int tid = vs[j][0] - '1';
      cout << table[tid][(vs[j].size() - 1) % table[tid].size()];
    }
    cout << "\n";
  }
  return (0);
}

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

using namespace std;

char num[8]={'a','d','g','j','m','p','t','w'};
int size[8]={3,3,3,3,3,4,3,4};
int main(void){
	string str;
	int n;
	scanf("%d",&n);
	for(int ddd=0;ddd<n;ddd++){
		int cnt=0;
		string res;
		cin >> str;
		for(int i=0;i<str.size();i++){
			if(i==0){
				if(str[i]!='0')cnt++;
			}else{
				if(str[i]!='0')cnt++;
				if(str[i]=='0'){
					if(str[i-1]=='0')continue;
					if(str[i-1]=='1'){
						cnt=(cnt+4)%5;
						if(cnt==0)res+='.';
						if(cnt==1)res+=',';
						if(cnt==2)res+='!';
						if(cnt==3)res+='?';
						if(cnt==4)res+=' ';
					}else res+=num[str[i-1]-'0'-2]+(cnt-1+size[str[i-1]-'0'-2])%size[str[i-1]-'0'-2];
					cnt=0;
				}
			}
		}

		cout << res << endl;
	}
	return 0;
}