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++: // 2006_KeitaiMessage.cpp
//
#include <bits/stdc++.h>
using namespace std;
int n;
string m;
char d[9][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 len[9] = {5, 3, 3, 3, 3, 3, 4, 3, 4};

vector<string> split(string &str, char sep) {
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while(getline(ss, buffer, sep)) {
    if(buffer != "") v.push_back(buffer);
  }
  return v;
}

void solve() {
  vector<string> v1 = split(m, '0');
  for_each(v1.begin(), v1.end(), [](string& x) {
      int a = x[0] - '0';
      int b = x.length();
      int c = (b <= len[a - 1] ? b - 1 : b % len[a - 1] - 1);
      cout << d[a - 1][c];
    });
  cout << endl;
}

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> m;
    solve();
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  cin.ignore();

  string rule[10] = {"", ".,!? ", "abc", "def", "ghi",
                     "jkl","mno", "pqrs", "tuv", "wxyz"};
  
  for(int i=0; i<n; i++){
    string s;
    getline(cin, s);

    string ans = "", temp = "";
    int before = 0, index = 0;
    for(int j=0; j<s.size(); j++){
      if(s[j] - '0' == 0){
        ans += temp;
        temp = "";
        index = 0;
      }else if(before == s[j] - '0'){
        temp = rule[before][index];
        index = (index+1)%rule[before].size();
      }else{
        temp = rule[s[j] - '0'][0];
        index = 1;
      }
      before = s[j] - '0';
    }

    cout << ans << endl;
  }
  
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; ++i)
typedef long long ll;
using namespace std;
const int INF = 1e9;

int main() {
    int n;
    cin >> n;
    while (n--) {
        string s;
        cin >> s;

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

        int cnt = 0;
        int now = 0;
        rep(i, s.size()) {
            if (s[i] == '0') {
                if (cnt != 0) {
                    cout << t[now][(cnt - 1) % t[now].size()];
                    cnt = 0;
                }
            } else {
                cnt++;
                now = s[i] - '0';
            }
        }
        cout << "\n";
    }

    return 0;
}

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

int main(){
  vector<vector<char> > v;
  vector<char> mv;

  mv.push_back(' ');mv.push_back('.');mv.push_back(',');mv.push_back('!');mv.push_back('?');
  v.push_back(mv);
  mv.clear();

  mv.push_back('c');mv.push_back('a');mv.push_back('b');
  v.push_back(mv);
  mv.clear();

  mv.push_back('f');mv.push_back('d');mv.push_back('e');
  v.push_back(mv);
  mv.clear();

  mv.push_back('i');mv.push_back('g');mv.push_back('h');
  v.push_back(mv);
  mv.clear();

  mv.push_back('l');mv.push_back('j');mv.push_back('k');
  v.push_back(mv);
  mv.clear();

  mv.push_back('o');mv.push_back('m');mv.push_back('n');
  v.push_back(mv);
  mv.clear();

  mv.push_back('s');mv.push_back('p');mv.push_back('q');mv.push_back('r');
  v.push_back(mv);
  mv.clear();

  mv.push_back('v');mv.push_back('t');mv.push_back('u');
  v.push_back(mv);
  mv.clear();

  mv.push_back('z');mv.push_back('w');mv.push_back('x');mv.push_back('y');
  v.push_back(mv);
  mv.clear();

  string s;
  int a,i,cou,n,cou2;
  while(cin >> s){ // 入力
    a=s.size();
    //cout <<a<< ' ';//////////////////
    i=0;
    cou2=0;
    while(i<a){//改行まで
      cou=0;
      n=0;
      while(s[i]!='0'&&i<a){//０まで
	if(n!=s[i]-'0')cou=0;
	n=s[i]-'0';
	i++;
	cou++;
      }
      i++;
      //cout <<n<< cou<< ' ';/////////////////
      if(cou!=0&&i<=a){
	if(n==8||n==2||n==3||n==4||n==5||n==6)cou=cou%3;
	else if(n==7||n==9)cou=cou%4;
	else if(n==1)cou=cou%5;

	cout<<v[n-1][cou];
	cou2++;
      }
    }
    if(cou2!=0)cout<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<bitset>
#include<map>
using namespace std;

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


string s;
bool input(){
  s="";
  if(!(cin>>s)){
    return false;
  }

  return true;
}


string solve(){
  string res = "";
  int n=-1;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0'){
      if(n==-1)continue;
      int tmp = s[i-1]-'0';
      res += list[tmp-1][n%list[tmp].size()];
      n=-1;
    }else{
      n++;
    }
  }
  return res;
}

int main(){
  int c=0;
  cin>>c;
  for(int i=0;i<c;i++){
    input();
    string ans = solve();
    if(ans.size()!=0)cout<<ans<<endl;
  }
}

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