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 LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int count(int y, int m, int d){
    int res = 0;
    res += d;
    res += (m-1) * 19;
    if(y%3){
        res += m / 2;
    }else{
        res += m - 1;
    }
    --y;
    res += y * 195;
    res += y / 3 * 5;
    return res;
}

string func(){
    string str;
    string codes[]={"*", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    cin >> str;
    int count=0;
    int bn=0;
    string res="";
    foreach(i, str){
        int j = i-'0';
        if(j==bn)++count;
        else{
            res += codes[bn][count%codes[bn].size()];
            bn=j;
            count=0;
        }
    }
    string ans = "";
    foreach(i, res){
        if(i!='*')ans+=i;
    }
    return ans;
}

int main(){
    int N;
    cin >> N;
    REP(i, N){
        cout << func() << endl;
    }
    return 0;
}

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

vector<string> button = {
  "",
  ".,!? ", "abc", "def",
  "ghi", "jkl", "mno",
  "oqrs", "tuv", "wxyz",
};

int main() {
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    int x = 0;
    int cnt = -1;
    string s; cin >> s;
    for (auto&& c : s) {
      int num = c - '0';
      if (num) {
        ++cnt;
      } else {
        if (x) cout << button[x][cnt % button[x].size()];
        cnt = -1;
      }
      x = num;
    }
    cout << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
string order;
vector<int> num;
vector<char> word;
int n;
char button[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 main()
{
  int but = 0,push = 0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> order;
    for(int j=0;j<order.size();j++){
      num.push_back((int)(order[j]-'0'));
    }
    for(int j=0;j<num.size();j++){
      if(1<=num[j] && num[j]<=9 && but==0){
	but = num[j];
      }else if(1<=num[j] && num[j]<=9 && but!=0){
	push++; //cout << "pushed" << endl;
      }else if(num[j]==0 && but && but!=1 && but!=7 && but!=9){
	word.push_back(button[but-1][push%3]); //cout << button[but-1][push%3] << endl;
	push = 0;
	but = 0;
      }else if(num[j]==0 && but && (but==7 || but==9)){
	word.push_back(button[but-1][push%4]); //cout << button[but-1][push%4] << endl;
	push = 0;
	but = 0;
      }else if(num[j]==0 && but && but==1){
	word.push_back(button[but-1][push%5]); //cout << button[but-1][push%4] << endl;
	push = 0;
	but = 0;
      }else if(num[j]==0 && !but){
	continue;
      }
    }
    for(int k=0;k<word.size();k++){
      cout << word[k];
    }
    cout << endl;
    word.clear();
    num.clear();
  }
  
  return 0;
  
}

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

int main(){
	int n;
	for(cin >> n; n--; ){
		string s;
		cin >> s;
		s += '0';

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

		int d = 0, t = 0;
		for(size_t i = 0; i < s.size(); ++i){
			int c = s[i] - '0';
			if(c == 0 || c != d){
				if(d != 0){
					cout << tbl[d][t];
				}
				d = c;
				t = 0;
			}
			else{
				t = (t + 1) % tbl[d].size();
			}
		}
		cout << endl;
	}
}

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

int main(){
  char l[10][6]={{}, {".,!? "}, {"abc"}, {"def"}, {"ghi"}, {"jkl"}, {"mno"}, {"pqrs"}, {"tuv"}, {"wxyz"}};
  //char **l={{}, {".,!? "}, {"abc"}, {"def"}, {"ghi"}, {"jkl"}, {"mno"}, {"pqrs"}, {"tuv"}, {"wxyz"}};
  int n;
  cin >> n;
  for(int k=0;k<n;k++){
    char c[1025];
    cin >> c;
    int size=0;
    for(int i=0;i<1025;i++){
      if(c[i]=='\0'||c[i]=='\n'){
        break;
      }
      size++;
    }

    int count=0;
    for(int i=0;i<size;i++){
      if(c[i]=='0'){
        if(i!=0){
          int num = (int)(c[i-1]-'0');
          int s=0;
          for(int j=0;j<7;j++){
            if(l[num][j]=='\0'){
              s=j;
              break;
            }
          }
          if(c[i]!=c[i-1])
            cout << l[num][(count-1)%s];
          count=0;
        }
      }else{
        count++;
      }
    }


    /*for(int i=1;i<size;i++){
      if(c[i-1]=='0'&&c[i]=='0') continue;
      else if(c[i-1]!='0'&&(c[i-1]==c[i]||c[i]!='0')){
      count++;
      }else if(c[i]=='0'){
      int s=0;
      int num = (int)(c[i-1]-'0');
      if(num==0) continue;
      for(int j=0;j<7;j++){
      if(l[num][j]=='\0'){
      s=j+1;
      break;
      }
      }
    //int num = static_const<int>(c[i-1]);
    if(s!=0)cout << l[num][count%s];
    count=0;
    }
    if(i==size-1) cout << endl;
    }*/

    cout << endl;
    for(int i=0;i<1025;i++){
      c[i]='\0';
    }
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

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

char now,before;
string in;


void solve(){
  now = '\n';
  before = 'N';
  int c=0,r=0;
  int index = 0;
  while(in[index++] == '0');
  
  for(int i = index-1; i < in.length(); i++){
    if(in[i] == '0'){
      if(c+r){
	now = s[c][r%s[c].length()];
	cout << now;
	c = r =0;
      }
    }else if(before == in[i]){
      r++;
    }else{
      c = in[i]-'0';
      r = 0;
    }
    before = in[i];
  }
  cout << endl;
}

int main(){
  int N;
  cin >> N;
  while(N--){
    cin.ignore();
    while(getline(cin,in)) solve();
  }
  return 0;
}