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++: // AOJ 2006
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
  string input;
  string trm = "cfilov";
  while (cin >> input) {
    char c = '\0';
    for (char btn : input) {
      if (c == '\0') {
        if (btn == '1') {
          c = '.';
        } else if (btn == '2') {
          c = 'a';
        } else if (btn == '3') {
          c = 'd';
        } else if (btn == '4') {
          c = 'g';
        } else if (btn == '5') {
          c = 'j';
        } else if (btn == '6') {
          c = 'm';
        } else if (btn == '7') {
          c = 'p';
        } else if (btn == '8') {
          c = 't';
        } else if (btn == '9') {
          c = 'w';
        }
      } else if (btn == '0') {
        cout << c;
        c = '\0';
      } else {
        if (c == 's' or c == 'z') {
          c -= 3;
        } else if (find(trm.begin(), trm.end(), c) != trm.end()) {
          c -= 2;
        } else if (c == '.') {
          c = ',';
        } else if (c == ',') {
          c = '!';
        } else if (c == '!') {
          c = '?';
        } else if (c == '?') {
          c = ' ';
        } else if (c == ' ') {
          c = '.';
        } else {
          c++;
        }
      }
    }
    cout << endl;
  }
}

C++: #include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main() {
	int a[1030];
	int k;
	stringstream sout;
	string b;
	int kari;
	while (cin >> b) {
		kari = 0;
		int rireki[10] = {0};
		k = b.size();
		for (int i = 0; i < k; i++) {
			sout.str("");
			sout.clear();
			sout << b[i];
			sout >> a[i];
		}
		for (int i = 0; i < k-1; i++) {
			if(a[i] != a[i+1] && a[i+1] == 0 && a[i] != 0) {
				kari = 1;
				if (a[i] == 1) {
					if(rireki[1] % 5 == 0) {
						printf(".");
					} else if (rireki[1] % 5 == 1) {
						printf(",");
					} else if (rireki[1] % 5 == 2) {
						printf("!");
					} else if (rireki[1] % 5 == 3) {
						printf("?");
					} else {
						printf(" ");
					}
					rireki[1] = 0;
				} else if (a[i] == 2) {
					//printf(" %d \n", rireki[2]);
					if(rireki[2] % 3 == 0) {
						printf("a");
					} else if (rireki[2] % 3 == 1) {
						printf("b");
					} else {
						printf("c");
					}
					rireki[2] = 0;
				} else if (a[i] == 3) {
					if (rireki[3] % 3 == 0) {
						printf("d");
					} else if (rireki[3] % 3 == 1) {
						printf("e");
					} else {
						printf("f");
					}
					rireki[3] = 0;
				} else if (a[i] == 4) {
					if (rireki[4] % 3 == 0) {
						printf("g");
					} else if (rireki[4] % 3 == 1) {
						printf("h");
					} else {
						printf("i");
					}
					rireki[4] = 0;
				} else if (a[i] == 5) {
					if (rireki[5] % 3 == 0) {
						printf("j");
					} else if (rireki[5] % 3 == 1) {
						printf("k");
					} else {
						printf("l");
					} 
					rireki[5] = 0;
				} else if (a[i] == 6) {
					if (rireki[6] % 3 == 0) {
						printf("m");
					} else if (rireki[6] % 3 == 1) {
						printf("n");
					} else {
						printf("o");
					}
					rireki[6] = 0;
				} else if (a[i] == 7) {
					if (rireki[7] % 4 == 0) {
						printf("p");
					} else if (rireki[7] % 4 == 1) {
						printf("q");
					} else if (rireki[7] % 4 == 2) {
						printf("r");
					} else {
						printf("s");
					}
					rireki[7] = 0;
				} else if (a[i] == 8) {
					if (rireki[8] % 3 == 0) {
						printf("t");
					} else if(rireki[8] % 3 == 1) {
						printf("u");
					} else {
						printf("v");
					}
					rireki[8] = 0;
				} else {
					if (rireki[9] % 4 == 0) {
						printf("w");
					} else if (rireki[9] % 4 == 1) {
						printf("x");
					} else if (rireki[9] % 4 == 2) {
						printf("y");
					} else {
						printf("z");
					}
					rireki[9] = 0;
				}
			} else {
				if (a[i] == 0 || (a[i] != a[i+1])) {
					rireki[a[i]] = 0;
					continue;
				}
				rireki[a[i]]++;
			}
		}
		if (kari == 1) {
			printf("\n");
			}
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
#define d_arr(arr, h, w) rep(i,(h) ){ cout << "["; rep(j,(w) ) { cout << (arr)[i][j] << ", "; } cout << "]" << endl;}

typedef pair<int ,int> P;

/*
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: 確定ボタン
 */

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


int main()
{
    int n;
    int index;
    int count=0;
    string s;
    int loop;
    cin >> loop;
    rep(i, loop)
    {
        string s;
        cin >> s;
        cout << s << endl;
        rep(j, s.size() )
        {
            string st;
            st[0] = s[j];
            n = atoi( &st[0] );
            //cout << n << endl;
            if( n == 0 && count == 0) { continue; }
            else if( n == 0 ) 
            { 
                cout << a[index - 1][(count - 1) % a[index - 1].size() ];  
                count = 0;
            }
            else
            {
                index = n;
                count++;
            }
        }
    }
    //if ( count > 0 ) { cout << a[index - 1][(count - 1) % 9]; count = 0; }
}