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 <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    ll t; cin >> t;
    vector<string> s(10);
    s[1] = ".,!? ";
    s[2] = "abc";
    s[3] = "def";
    s[4] = "ghi";
    s[5] = "jkl";
    s[6] = "mno";
    s[7] = "pqrs";
    s[8] = "tuv";
    s[9] = "wxyz";
    while(t--){
        string a; cin >> a;
        ll now = -1;
        ll id = 0;
        ll n = a.size();
        rep(i,n){
            ll u = a[i] - '0';
            if(u == 0){
                if(now != -1) cout << s[now][id];
                now = -1;
                continue;
            }
            if(now != u){
                now = u;
                id = 0;
            }else{
                id = (id + 1) % s[now].size();
            }
        }
        cout << endl;
    }
}

C++: // 2016-11-25
#include <iostream>
#include <string>

char c[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 l[10] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4};

int main() {
	int n;
	std::string s;
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> s;
		int m = s.length();
		int x = 0;
		int y = 0;
		for (int j = 0; j < m; j++) {
			int a = int(s[j] - '0');
			if (a == 0) {
				if (x != 0) {
					std::cout << c[x][y];
					x = 0;
				}
			} else {
				if (a == x) {
					y = (y + 1) % l[x];
				} else {
					x = a;
					y = 0;
				}
			}
		}
		std::cout << std::endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define rep(i,n) for(int i=0; i<(n); i++)
#define per(i,n) for(int i=(n)-1; i>=0; i--)
#define all(v) v.begin(), v.end()
#define debug(var) do{cout << #var << " : "; print(var); } while(0)
using namespace std;
typedef long long ll;
void print() { cout << endl; }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...); }
template <class T> void print(vector<T> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec); } }
const int INF = 1e9;
const int MOD = 1e9+7;

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n; cin >> n;
	rep(nn, n) {
		string s; cin >> s;
		string ans;
		int loc = -1;
		int pushed = 0;

		rep(i, s.size()) {
			char c = s[i];
			int num = c - '0';
			if (num==0) {
				if (loc==-1) continue;
				pushed %= button[loc].size();
				ans += button[loc][pushed];
				loc = -1;
				pushed = 0;
			}
			num--;
			if (loc==-1) loc=num;
			else pushed++;
		}

		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>

#define PI 3.14159265359

#define INF 1000000;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)

using namespace std;


/*
class ElectronicPetEasy
{
public:
	string isDifficult(int st1, int p1, int t1, int st2, int p2, int t2)
	{
		
	}
};
*/
string button[10] = {"12345678", ".,!? ", "abc", "def", "ghi", "jkl" , "mno", "pqrs", "tuv", "wxyz" };


int main()
{
	int n;
	string s;
	
	cin >> n;
	rep(j,n)
	{
		cin >> s;
		int bnum=0, pushnum=0;
		REP(s.size())
		{
			if (s[i] == '0' && pushnum > 0)
			{
				cout << button[bnum][(pushnum + button[bnum].size()-1) % button[bnum].size()];
				pushnum = 0;
				bnum = 0;
				continue;
			}
			if (s[i] != '0'){pushnum++; bnum = s[i]-'0';}
		}
		cout << 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;
    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])){
	    count=count-strlen(bot[flag]);
	  }
	  cout<<bot[flag][count];
	}
	count=0;
	flag=0;
      }
    }
    cout<<endl;
  }
  }
  return 0;
}

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

using namespace std;

long long INF=1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin>>n;

    string s1,s2,s3,s4,s5,s6,s7,s8,s9;
    s1=".,!?";s2="abc";s3="def";s4="ghi";s5="jkl";
    s6="mno";s7="pqrs";s8="tuv";s9="wxyz";
    
    for(int i=0;i<n;i++){
        string S;
        cin>>S;
        int sum=0;
        char c;
        string s;
        bool f=false;
        for(int j=0;j<S.size();j++){
            if(S[j]!='0'){
                f=true;
                c=S[j];
                sum++;
                if(c=='1')s=s1;if(c=='2')s=s2;if(c=='3')s=s3;
                if(c=='4')s=s4;if(c=='5')s=s5;if(c=='6')s=s6;
                if(c=='7')s=s7;if(c=='8')s=s8;if(c=='9')s=s9;
            }
            else{
                sum--;
                if(s==s1||s==s7||s==s9)sum%=4;
                else sum%=3;
                if(f)cout<<s[sum];
                sum=0;
                f=false;
            }
        }
        cout<<endl;
    }
}