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<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,e;
  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){
	    e=count%5;
	    if(e!=0)
	      cout<<m[d-1][e-1];
	    else cout<<m[d-1][3];
	  }
	  else if(d==7 || d==9){
	    e=count%4;
	    if(e!=0)
	      cout<<m[d-1][e-1];
	    else cout<<m[d-1][3];
	  }
	  else {
	    e=count%3;
	    if(e!=0)
	      cout<<m[d-1][e-1];
	    else cout<<m[d-1][2];
	  }
	  count=0;
	}
      }
    }
    cout<<endl;
  }
  return 0;
}

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

vector<vector<char> > buttons { {'.',',','!','?',' '}, {'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'}};

char push(int button, int times) {
  return buttons[button - 1][(times - 1) % buttons[button - 1].size()];
}

void solve(string s) {
  int t = 0;
  int before = 0;
  for (auto c : s) {
    if (c == '0') {if (t != 0) cout << push(before, t); t = 0;}
    else {
      t++;
      before = atoi(&c);
    }
  }
  if (t!= 0) cout << push(before, t);
  cout << endl;
};

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    solve(s);
  }
}

C++: #include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;

int main()
{
    string phone[10] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    int n;
    string input;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> input;
        int l = input.length();
        int j = 0;
        while(1){
            int c1 = 0;
            while(c1 == 0 && j < l){
                c1 = input[j] - '0';
                j++;
            }
            if(j == l) break;
            int l2 = phone[c1 - 1].length();
            int k = 0;
            while(c1 == input[j] - '0'){
                j++;
                k++;
            }
            cout << phone[c1 - 1][k % l2];
        }
        cout << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;

char letter[] = {'.', ',', '!', '?', ' ', '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'};

char output(int b, int c)
{
    switch (b) {
    case 1:
        return letter[0 + (c % 5)];
        break;
    case 2:
        return letter[5 + (c % 3)];
        break;
    case 3:
        return letter[8 + (c % 3)];
        break;
    case 4:
        return letter[11 + (c % 3)];
        break;
    case 5:
        return letter[14 + (c % 3)];
        break;
    case 6:
        return letter[17 + (c % 3)];
        break;
    case 7:
        return letter[20 + (c % 4)];
        break;
    case 8:
        return letter[24 + (c % 3)];
        break;
    case 9:
        return letter[27 + (c % 4)];
        break;
    }
}

int main()
{
    int n;
    cin >> n;
    for (int cnt = 0; cnt < n; cnt++) {
        string str;
        cin >> str;
        int button = -1;
        int count = -1;
        for (char c : str) {
            if (c == '0') {
                if (button != -1) {
                    cout << output(button, count);
                }
                count = -1;
                button = -1;
            } else {
                button = c - '0';
                count++;
            }
        }
        cout << endl;
    }
    return 0;
}

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

int main(void)
{
  int n;
  char buf[1026];
  int count=0;
  int tmp;

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

C++: #include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int main() {
	char m[10][10] = {
		"",
		".,!? ",
		"abc",
		"def",
		"ghi",
		"jkl",
		"mno",
		"pqrs",
		"tuv",
		"wxyz",
	};

	int n; cin >> n;
	for (int t = 0; t < n; ++t) {
		string ans = "";
		string str; cin >> str;
		int Key = -1, cnt = 0;
		for (int i = 0; i < str.size(); ++i) {
			int key = str[i]-'0';
			if (key == 0) {
				if (cnt > 0) {
					ans += m[Key][(cnt-1)%strlen(m[Key])];
				}
				cnt = 0;
			}
			else {
				Key = key;
				++cnt;
			}
		}
		cout << ans << endl;
	}
}