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<cstring>

using namespace std;

string outputWord(string str);

int main() {
  int n;
  string tmp;
  cin>>n;
  getline(cin, tmp);
  while(n--) {
    string inputStr;
    getline(cin, inputStr);    
    cout<<outputWord(inputStr)<<endl;
  }
}

string outputWord(string str) {
  string ans, tmp;

  for(int i=0; i<str.length(); i++) {
    switch(str[i]) {
    case '0':
      ans += tmp;
      tmp.clear();
      break;
    case '1':
      if(tmp.length()==0 || tmp==" ") {
	tmp = ".";
      }
      else if(tmp == ".") {
	tmp = ",";
      }
      else if(tmp == ",") {
	tmp = "!";
      }
      else if(tmp == "!") {
	tmp = "?";
      }
      else if(tmp == "?") {
	tmp = " ";
      }
      break;
    case '2':
      if(tmp.length()==0 || tmp=="c") {
	tmp = "a";
      }
      else if(tmp == "a") {
	tmp = "b";
      }
      else if(tmp == "b") {
	tmp = "c";
      }
      break;
    case '3':
      if(tmp.length()==0 || tmp=="f") {
	tmp = "d";
      }
      else if(tmp == "d") {
	tmp = "e";
      }
      else if(tmp == "e") {
	tmp = "f";
      }
      break;
    case '4':
      if(tmp.length()==0 || tmp=="i") {
	tmp = "g";
      }
      else if(tmp == "g") {
	tmp = "h";
      }
      else if(tmp == "h") {
	tmp = "i";
      }
      break;
    case '5':
      if(tmp.length()==0 || tmp=="l") {
	tmp = "j";
      }
      else if(tmp == "j") {
	tmp = "k";
      }
      else if(tmp == "k") {
	tmp = "l";
      }
      break;
    case '6':
      if(tmp.length()==0 || tmp=="o") {
	tmp = "m";
      }
      else if(tmp == "m") {
	tmp = "n";
      }
      else if(tmp == "n") {
	tmp = "o";
      }
      break;
    case '7':
      if(tmp.length()==0 || tmp=="s") {
	tmp = "p";
      }
      else if(tmp == "p") {
	tmp = "q";
      }
      else if(tmp == "q") {
	tmp = "r";
      }
      else if(tmp == "r") {
	tmp = "s";
      }
      break;
    case '8':
      if(tmp.length()==0 || tmp=="v") {
	tmp = "t";
      }
      else if(tmp == "t") {
	tmp = "u";
      }
      else if(tmp == "u") {
	tmp = "v";
      }
      break;
    case '9':
      if(tmp.length()==0 || tmp=="z") {
	tmp = "w";
      }
      else if(tmp == "w") {
	tmp = "x";
      }
      else if(tmp == "x") {
	tmp = "y";
      }
      else if(tmp == "y") {
	tmp = "z";
      }
      break;
    }
  }

  return ans;
}

C++: #include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
int main() {
	string a;
	string d[10] = { "",".,!?","abc","def","ghi","jkl","mno",
		"pqrs","tuv","wxyz" };
	while (cin >> a) {
		char b;
		string c = "";
		for (int i = 0; i < a.length(); i++) {
			b = a[i];
			int i2 = i;
			while (a[i] == b) i++;
			int sum = i - i2;
			sum %= d[(int)b - '0'].length();
			sum--;
			c += d[(int)b-'0'][sum];
		}
		cout << c << endl;
	}
}

C++: #include<iostream>
#include<cstdio>
#include<string>

using namespace std;

int main(){

	string data[] = { ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
	char inp;
	int n, cnt, num;
	string ans;

	cin >> n;

	getchar();

	for (int i = 0; i < n; i++){

		cnt = 0;
		ans = ("");

		while (1){

			inp = getchar();

			if (inp == '\n') break;
			if (inp != '0'){
				num = inp - '0';
				cnt++;
			}
			else{
				if (cnt > 0){
					ans += data[num-1][(cnt-1)%data[num-1].size()];
					cnt = 0;
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

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

char data[10][5] = {'E','E','E','E','E',
		    '.', ',', '!' ,'?' ,' ',
		    'a', 'b', 'c', 'E', 'E',
		    'd','e','f','E','E',
		    'g','h','i','E','E',
		    'j','k','l','E','E',
		    'm','n','o','E','E',
		    'p','q','r','s','E',
		    't','u','v','E','E',
		    'w','x','y','z','E'};

string in;
int col=-1, row=0;
int num;
int state = 0;

int main(){
  int N;
  cin >> N;
  while(N--){
    cin.ignore();
    while(getline(cin,in)){
      bool onlyzero = true;
      for(int i = 0; i < in.length(); i++)
	if(in[i] != '0') onlyzero = false;

      if(onlyzero){
	cout << endl;
	continue;
      }

      for(int i = 0; i < in.length(); i++){
	if(in[i] == '0'){
	  if(col == -1) col++;
	  if(row >= 2 && row <= 6 || row == 8) num = 3;
	  else if(row == 1) num = 5;
	  else num = 4;
	
	  if(data[row][col%num] != 'E'){
	    cout << data[row][col%num];
	    state = 1;
	  }
	  col = -1;
	  row = 0;
	}else{
	  col++;
	  row=in[i]-'0';
	}
	if(i == in.length()-1){
	  if(state == 1) cout << endl;
	  state = 0;
	  col = -1;
	  row = 0;
	}
	
      }
      if(data[row][col%num] != 'E'){
	cout << data[row][col%num];
	//state = 1;
      }
      if(state == 1) cout << endl;
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
  string code[] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
  int len[] = {5, 3, 3, 3, 3, 3, 4, 3, 4};
  
  int N;
  cin >> N;
  while(N--){
    string s;
    cin >> s;
    char c = '#';
    int idx = 0;
    for(int i = 0; i < s.size(); i++){
      if(s[i] == '0'){
	if(c != '#') cout << c;
	c = '#';
	idx = 0;
      } else {
	c = code[s[i]-'0'-1][idx];
	idx = (idx + 1) % len[s[i]-'0'-1];
      }
    }
    cout << endl;
  }

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    char code[][5] = {
        {0,0,0,0,0},
        {'.',',','!','?',' '},
        {97,98,99,0,0},
        {100,101,102,0,0},
        {103,104,105,0,0},
        {106,107,108,0,0},
        {109,110,111,0,0},
        {112,113,114,115,0},
        {116,117,118,0,0},
        {119,120,121,122,0}
    };
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string input;
        cin >> input;
        int num = 0;
        int index = 0;
        for (int j = 0; j < input.length(); ++j) {
            if (input[j] == '0') {
                cout << code[num][index];
                num = 0;
                index = 0;
            } else if (!index && !num) {
                num = input[j] - '0';
            } else {
                while(num) {
                    if (++index == 5) index = 0;
                    if (code[num][index]) break;
                }
            }
        }
        cout << endl;
    }
    return 0;
}