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 rep1(i,n) for(int i=1;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;

int main(){
    vector<string> k = {
        "",
        ".,!? ",
        "abc",
        "def",
        "ghi",
        "jkl",
        "mno",
        "pqrs",
        "tuv",
        "wxyz"
    };
    int n;
    cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        string ans = "";
        int ct = 0, now = 0;
        rep(j, s.size()){
            int x = s[j]-'0';
            if(x == 0){
                if(now == 0) continue;
                ans += k[now][ct%k[now].size()];
                now = 0;
            }else{
                if(now == x){
                    ct++;
                }else{
                    now = x;
                    ct = 0;
                }
            }
        }
        cout << ans << endl;
    }
            
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){   
  char m[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 a,count=0,c[100],d;
  char b[100][1024];
  cin>>a;
  for(int i=0;i<a;i++){
    scanf("%s",b[i]);
    c[i]=strlen(b[i]);
    for(int j=0;j<c[i];j++){

      if(b[i][j]!='0')count++;
      else{
	if(b[i][j-1]!=0){
	  d=(int)(b[i][j-1])-48;
	  if(d==1)
	    if(count%5==0)
	      cout<<m[d-1][4];
	    else 
	      cout<<m[d-1][count%5-1];
	  
	  else if(d==7 || d==9)
	    if(count%4==0)
	      cout<<m[d-1][3];
	    else
	      cout<<m[d-1][count%4-1];
	  
	  else
	    if(count%3==0)
	      cout<<m[d-1][2];
	    else
	      cout<<m[d-1][count%3-1];
	  count=0;
	}
      }
    }
    cout<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    char ans[][10] = {
        {},
        {'.',',','!','?',' '},
        {'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 n; cin >> n;
    rep(i,n){
        string s(100000,0);
        cin >> s;
        int temp = 0;
        int counter =-1 ;
        for(int k = 0;k<s.size();k++){
            int now = int(s[k]-48);
            if(k == 0){temp = now;counter++;}
            else if(now != 0){
                temp = now;counter++;}
            if(now == 0){
                if(temp  == 9 || temp == 7)
                    counter%=4;
                else if(temp != 1&& temp != 7 && temp!= 9)
                    counter%=3;
                else if(temp == 1)
                    counter %=5;
                cout << ans[temp][counter];
                temp = 0;counter =-1;;
            }
        }
        cout << endl;
    }
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){   
  char m[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 a,count=0,c[100],d;
  char b[100][1024];
  cin>>a;
  for(int i=0;i<a;i++){
    scanf("%s",b[i]);
    c[i]=strlen(b[i]);
    for(int j=0;j<c[i];j++){
      if(b[i][j]!='0')count++;
      else
	if(b[i][j-1]!=0){
	  d=(int)(b[i][j-1])-48;

	  if(d==1)
	    if(count%5!=0)
	      cout<<m[d-1][count%5-1];
	    else cout<<m[d-1][3];

	  else if(d==7 || d==9)
	    if(count%4!=0)
	      cout<<m[d-1][count%4-1];
	    else cout<<m[d-1][3];

	  else
	    if(count%3!=0)
	      cout<<m[d-1][count%3-1];
	    else cout<<m[d-1][2];
	  
	  count=0;
	}
    }
    cout<<endl;
  }
  return 0;
}

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

int main(){
  vector<string> num = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

  int n;
  cin >> n;
  string ans;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    
    ans = "";
    int j = 0;
    stack<int> st;
    for(int j = 0; j < s.length(); j++){
      if(s[j] == '0'){
        if(st.empty())continue;
        ans += num[st.top()][(st.size() - 1) % num[st.top()].size()];

        while(!st.empty())st.pop();
      }else{
        st.push(s[j] - '0');
      }
    }
    cout << ans << endl;
  }
}