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 <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<vector<char> > C;
	C.push_back({ '.',',','!','?',' ' });
	C.push_back({ 'a','b','c' });
	C.push_back({ 'd','e','f' });
	C.push_back({ 'g','h','i' });
	C.push_back({ 'j','k','l' });
	C.push_back({ 'm','n','o' });
	C.push_back({ 'p','q','r','s' });
	C.push_back({ 't','u','v' });
	C.push_back({ 'w','x','y','z' });
	int N;
	cin >> N;
	REP(i, N) {
		string S;
		cin >> S;
		int ind = 0;
		string ans = "";
		while (ind < SZ(S)) {
			char c = S[ind];
			ind++;
			if (c == '0') {
				continue;
			}
			int cnt = 0;
			while (S[ind] != '0') {
				ind++;
				cnt++;
			}
			ans += C[c - '1'][cnt % SZ(C[c-'1'])];
		}
		cout << ans << endl;
	}
	return 0;
}

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

char hyo[9][5];

char moji(int char_, int count);

int main(void)
{
	int i1,i2;
	char c = 'a';
	char cc;
	string s;
	int n;
	int m;
	int count;

		/* syokika */
		for(i1=0;i1<9;i1++){	
			for(i2=0;i2<5;i2++){
				hyo[i1][i2] = '1';
			}
		}


		/* hyo sakusei */
		hyo[0][0] = '.';
		hyo[0][1] = ',';
		hyo[0][2] = '!';
		hyo[0][3] = '?';
		hyo[0][4] = ' ';


		for( i1=1; i1<9; i1++){
			for(i2=0; i2<4; i2++){
				
				if(i2 == 3) {

					if( i1 == 6 || i1 == 8) {}
					else continue;
				}

				hyo[i1][i2] = c;
				c++;
			}
		}



		cin >> n;

		for(i2=0;i2<n;i2++){


			cin >> s;

			count = 0;
			m = 0;
			for(i1=0;i1<s.size();i1++){
			

				if( s[i1]=='0'){
					if(m != 0){
						cc = moji(m,count);
						count = 0;
						m = 0;
					    cout << cc;
					}
				}
				else{

					c = s[i1];
					m = c - 48;
					count++;
				}
			}

			cout << endl;


		}

	return 0;

}


char moji(int char_, int count)
{

	int n;
	count--;
	if( char_ == 1){
		n = count%5;
	}
	else if( char_ == 7 || char_ == 9){
		n = count%4;
	}
	else {
		n = count%3;
	}

	return hyo[char_-1][n];
}

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

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

/*

    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: 確定ボタン 
*/

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

string conv(string str) {
  string res = "";
  char c = 'X';
  int num = 0;
  for (int i = 0; i < str.size(); ++i) {
    if (str[i] == '0') {
      if (num > 0) {
	int bu = c - '0';
	int ord = (num - 1) % button[bu].size();
	char add = button[bu][ord];
	res += add;
	num = 0;
      }
    }
    else {
      c = str[i];
      ++num;
    }
  }
  return res;
}

int main() {
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    string str; cin >> str;
    cout << conv(str) << endl;
  }
}

C++: #include "bits/stdc++.h"

using namespace std;

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

    int n;cin>>n;
    vector<string> v;
    v.push_back("");v.push_back(".,!? ");v.push_back("abc");
    v.push_back("def");v.push_back("ghi");v.push_back("jkl");
    v.push_back("mno");v.push_back("pqrs");v.push_back("tuv");
    v.push_back("wxyz");
    for(int i=0;i<n;i++){
        string s;cin>>s;
        s+='0';
        string res="";
        int cnt=0,idx=0;
        for(int j=0;j<(int)s.length();j++){
            if(s[j]-'0' ==0){
                if(cnt==0) continue;
                res+=v[idx][(cnt-1)%(v[idx].length())];
                cnt=0;
            }
            else{
                idx=s[j]-'0';
                cnt++;
            }
        }
        cout<<res<<endl;
    }
}