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>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;

int main() {
  string strs[9] = {{".,!? "}, {"abc"},  {"def"}, {"ghi"}, {"jkl"},
                    {"mno"},   {"pqrs"}, {"tuv"}, {"wxyz"}};
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string ans = "", sw;
    cin >> sw;
    int a = 0, b = 0;
    for (int j = 0; j < sw.size(); j++) {
      if (sw[j] == '0' && b >= 1) {
        ans += strs[a - 1][(b + strs[a - 1].size() - 1) % strs[a - 1].size()];
        a = 0, b = 0;
      }
      if (sw[j] == '0')
        continue;
      else {
        a = sw[j] - '0';
        b++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
#define rep(i,j) for(int i = 0; i < (j); i++)
int main(){
	int n;
	cin >> n;
	string c[] = {"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};	
	while(n--){
		string str;
		cin >> str;
		string ans = "";
		rep(i,str.size()){
			if(str[i] == '0')continue;
			int sub = i;
			while(str[i] == str[++sub]);
			ans += c[str[sub-1]-48][(sub-i-1)%c[str[sub-1]-48].size()];
			i = sub;
		}
		cout << ans << endl;
	}	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){

  int n, cnt = 0, num = 0;
  string str, phone;

  cin >> n;

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









return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>

using namespace std;
typedef long long ll;

ll N;
vector<vector<char>> ans;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		char S[1030] = {};
		vector<char> vec;
		ans.push_back(vec);
		cin >> S;
		for (int j = 1; j < 1030; j++) {
			if (S[j] == 0)break;
			if (S[j] == '0' && S[j - 1] != '0') {
				for (int k = j - 1; k >= 0; k--) {
					if (S[k] != S[j - 1] || k == 0) {
						if (k == 0 && S[0] != '0')k--;
						switch (S[j - 1]) {
						case '1':
							switch ((j - k) % 5) {
							case 0:
								ans[i-1].push_back('?');
								break;
							case 1:
								ans[i-1].push_back(' ');
								break;
							case 2:
								ans[i-1].push_back('.');
								break;
							case 3:
								ans[i-1].push_back(',');
								break;
							case 4:
								ans[i-1].push_back('!');
							}
							break;
						case '2':
							ans[i-1].push_back('a' + (j - k - 2) % 3);
							break;
						case '3':
							ans[i-1].push_back('d' + (j - k - 2) % 3);
							break;
						case '4':
							ans[i-1].push_back('g' + (j - k - 2) % 3);
							break;
						case '5':
							ans[i-1].push_back('j' + (j - k - 2) % 3);
							break;
						case '6':
							ans[i-1].push_back('m' + (j - k - 2) % 3);
							break;
						case '7':
							ans[i-1].push_back('p' + (j - k - 2) % 4);
							break;
						case '8':
							ans[i-1].push_back('t' + (j - k - 2) % 3);
							break;
						case '9':
							ans[i-1].push_back('w' + (j - k - 2) % 4);
						}
						break;
					}
				}
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < ans[i].size(); j++)cout << ans[i][j];
		cout << endl;
	}
	return 0;
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	vector<string> a(10);
	a[1] = ".,!? ";
	a[2] = "abc";
	a[3] = "def";
	a[4] = "ghi";
	a[5] = "jkl";
	a[6] = "mno";
	a[7] = "pqrs";
	a[8] = "tuv";
	a[9] = "wxyz";
	a[0] = "";
	
	string str;
	cin>> str;
	int n = str.size();
	int pre;
	int cnt = 0;
	for(int i=0;i<n;i++){
		int num = str[i] - '0';
		if(i==0){
			pre = num;
			continue;
		}
		if(pre == num){
			cnt++;
		}else{
			if(pre != 0){
				cout<< a[pre][cnt % a[pre].size()];
			}
			cnt = 0;
		}
		pre = num;
	}
	cout<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	int n;
	cin>> n;
	for(int i=0;i<n;i++){
		solve();
	}
	
	return 0;
}