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 <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int lim[] = {5, 3, 3, 3, 3, 3, 4, 3, 4};
string inpchar[] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

signed main() {
    int n; cin >> n;
    rep(i,0,n) {
        string s, ans; cin >> s;
        int inp = -1, mo = -1;
        rep(j,0,s.length()) {
            if(s[j] == '0') {
                if(inp != -1) {
                    ans += inpchar[inp][mo];
                    mo = -1;
                    inp = -1;
                }
            }
            else {
                inp = s[j] - '1';
                mo = (mo + 1) % lim[inp];
            }
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>

using namespace std;

vector<string>split(string s){
  vector<string>res;
  int pre = 0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0'){
      res.push_back(s.substr(pre,i-pre));
      pre = i+1;
    }
  }
  return res;
}

int main(void){

  map<char,string>mp;
  mp['0']="";
  mp['1']=".,!? ";
  mp['2']="abc";
  mp['3']="def";
  mp['4']="ghi";
  mp['5']="jkl";
  mp['6']="mno";
  mp['7']="pqrs";
  mp['8']="tuv";
  mp['9']="wxyz";
  
  int n;
  cin >> n;

  while(n--){
    string s;
    cin >> s;
    vector<string>res = split(s);
    for(int i=0;i<res.size();i++)
      cout << mp[res[i][0]][(res[i].size()-1)%max(1,(int)mp[res[i][0]].size())];
    cout << endl;
  }
  
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
using namespace std;
int n;

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