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 <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
/*

    1: . , ! ? (スペース)
    2: a b c
    3: d e f
    4: g h i
    5: j k l
    6: m n o
    7: p q r s
    8: t u v
    9: w x y z
    0: 確定ボタン */
char keitai[10][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'},
};
string str;
int main()
{
  int n;
  cin >>n;
  for(int i = 0;i < n;i++){
    int cnt[15] = {0};
    cin >>str;
    for(int i = 0;i < str.length();i++){
      if(i >0&&str[i]=='0'&&str[i-1]!='0'){
	if((str[i-1]=='1')){
	  cout <<keitai[(str[i-1]-'0')-1][(cnt[(str[i-1]-'0')]-1)%5];
	  cnt[str[i-1]-'0'] = 0;
	}
	else if((str[i-1]=='7'||str[i-1]=='9')){
	  cout <<keitai[(str[i-1]-'0')-1][(cnt[str[i-1]-'0']-1)%4];
	  cnt[str[i-1]-'0'] = 0;
	}else{
	  cout <<keitai[(str[i-1]-'0')-1][(cnt[str[i-1]-'0']-1)%3];
	  cnt[str[i-1]-'0'] = 0;	  
	}
      }
      if(str[i] !='0'){
	cnt[str[i]-'0'] +=1;
      }
    }
    cout <<endl;
  }
  return 0;
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;


int main() {
	int n;
	vs button(10, "");
	vi buttonnum(10, 0);

	button[0] = "";
	button[1] = ".,!? ";
	button[2] = "abc";
	button[3] = "def";
	button[4] = "ghi";
	button[5] = "jkl";
	button[6] = "mno";
	button[7] = "pqrs";
	button[8] = "tuv";
	button[9] = "wxyz";

	cin >> n;
		REP(k, n) {
			string input;
			cin >> input;
			string output = "";
			int size = input.size();
			int lastnum = 0;

			REP(i, size) {
				switch(input[i]) {
				case '0':
					if(lastnum) {
						output += button[lastnum][(buttonnum[lastnum]-1)%button[lastnum].size()];
						buttonnum[lastnum] = 0;
						lastnum = 0;
						break;
					}
				case '1':
				case '2':
				case '3':
				case '4':
				case '5':			
				case '6':			
				case '7':			
				case '8':			
				case '9':
					++buttonnum[input[i]-'0'];
					lastnum = input[i]-'0';
					break;
				}
			}

			cout << output << endl;
	
		
	}
}

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

#define int				long long
#define FOR( i, m, n )	for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )		FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )		(a).begin(), (a).end()
#define MP				make_pair

typedef pair<int, int> P;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
	int n, cnt;
	char ch1, ch2;
	char number[10][6] = {
		{},
		{ 5, '.', ',', '!', '?', ' ' },
		{ 3, 'a', 'b', 'c' },
		{ 3, 'd', 'e', 'f' },
		{ 3, 'g', 'h', 'i' },
		{ 3, 'j', 'k', 'l' },
		{ 3, 'm', 'n', 'o' },
		{ 4, 'p', 'q', 'r', 's' },
		{ 3, 't', 'u', 'v' },
		{ 4, 'w', 'x', 'y', 'z' }
	};

	cin >> n; cin.get( ch1 );
  REP( i, n ){
    while( cin.get( ch1 ), ch1 != '\n' ){
      cnt = 0;
      while( cin.get( ch2 ), ch2 == ch1 ) cnt++;

      if( ch2 == '0' ){
        cout << number[ch1 - '0'][cnt % number[ch1 - '0'][0] + 1];
      }else{
        cin.putback( ch2 );
      }
    }
    cout << endl;
  }

}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  char button[11][11]={
    {'.',',','!','?',' '},
    {'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;
  for(int j=0;j<n;j++){
    string s;
    cin>>s;
    int cnt=0,index=-1;
    for(int i=0;i<s.size();i++){
      if(s[i]=='0'){
        if(index==-1){
          cnt=0;
          continue;
        }
        cnt--;
        cnt%=strlen(button[index]);
        cout<<button[index][cnt]<<flush;
        cnt=0;
        index=-1;
      }else{
        cnt++;
        index=s[i]-'1';
      }
    }
    cout<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	cin>>n;
	string str,num[10]={"0","1","2","3","4","5","6","7","8","9"};
	string s[10]={" ",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	for(int i=0;i<n;i++){
		cin>>str;
		for(int j=0;j<str.size();j++){
			for(int k=1;k<=9;k++){
				if(num[k][0]==str[j]){
					int cnt=-1;
					while(str[j]!='0'){
						cnt++;
						j++;
					}
					string S=s[k];
					cout<<S[cnt%S.size()];
				}
			}
		}
		cout<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

string keitai[]{".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main(){
	string s;
	while(cin>>s){
		int cnt=0;
		string ans;
		rep(i,s.size()){
			if(s[i]=='0'){
				if(cnt)ans+=keitai[s[i-1]-'1'][(cnt-1)%keitai[s[i-1]-'1'].size()];
				cnt=0;
			}
			else cnt++;
		}
		if(ans!="")cout<<ans<<endl;
	}
}