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<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    char ans[][10] = {
        {},
        {'.',',','!','?',' '},
        {'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;
    rep(i,n){
        string s;
        cin >> s;
        int temp = 0;
        int counter =-1 ;
        for(int k = 0;k<s.size();k++){
            int now = int(s[k]-48);
            if(k == 0){temp = now;counter++;}
            else if(now != 0){
                temp = now;counter++;}
            if(now == 0){
                if(temp  == 9 || temp == 7)
                    counter%=4;
                else if(temp != 1&& temp != 7 && temp!= 9)
                    counter%=3;
                else if(temp == 1)
                    counter %=5;
                cout << ans[temp][counter];
                temp = 0;counter =-1;;
            }
        }
        cout << endl;
    }
}

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

int main(int argc, char *argv[])
{
    string map[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno",
        "pqrs", "tuv", "wxyz"};
    string line;
    int n, cnt, num;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> line;
        cnt = 0;
        for (int j = 0; j < line.length(); ++j) {
            if (line[j] == '0') {
                if (j == 0 || line[j - 1] == '0')
                    continue;
                num = line[j - 1] - '0';
                cout << map[num][(cnt - 1) % map[num].length()];
                cnt = 0;
            } else if (line[j] != '0') {
                cnt++;
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<map>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string tmp[]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  string str;
  int i,l,cnt1,cnt2,n;
  cin >>n;
  for(int v=0;v<n;v++){
    cin >> str;
    l=str.size();
    cnt1=cnt2=0;
    for(int i=0;i<l;i++){
      if(str[i]=='0'){
	if(cnt2!=0){
	  cout << tmp[cnt1][(cnt2%tmp[cnt1].size()==0)?tmp[cnt1].size()-1:cnt2%tmp[cnt1].size()-1];
	}
	cnt1=cnt2=0;
      } else {
	if(cnt1==0){
	  cnt1=str[i]-'0';
	  cnt2++;
	}else{
	  cnt2++;
	}
      }
    }
    puts("");
  }
}

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

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  vector<char> bot[9];
  bot[0].push_back('.');
  bot[0].push_back(',');
  bot[0].push_back('!');
  bot[0].push_back('?');
  bot[0].push_back(' ');
  bot[1].push_back('a');
  bot[1].push_back('b');
  bot[1].push_back('c');
  bot[2].push_back('d');
  bot[2].push_back('e');
  bot[2].push_back('f');
  bot[3].push_back('g');
  bot[3].push_back('h');
  bot[3].push_back('i');
  bot[4].push_back('j');
  bot[4].push_back('k');
  bot[4].push_back('l');
  bot[5].push_back('m');
  bot[5].push_back('n');
  bot[5].push_back('o');
  bot[6].push_back('p');
  bot[6].push_back('q');
  bot[6].push_back('r');
  bot[6].push_back('s');
  bot[7].push_back('t');
  bot[7].push_back('u');
  bot[7].push_back('v');
  bot[8].push_back('w');
  bot[8].push_back('x');
  bot[8].push_back('y');
  bot[8].push_back('z');
  int n;
  cin >> n;
  for (int z = 0; z < n; z++) {
    string s;
    cin >> s;
    int len = s.size();
    string res = "";
    int index = 0;
    while (index < len) {
      while (index < len and s[index] == '0') index++;
      if (index >= len) break;
      int c = 0;
      char ch = s[index];
      index++;
      while (ch == s[index]) {
	c++;
	index++;
      }
      res += bot[ch-'1'][c%bot[ch-'1'].size()];
      index++;
    }
    cout << res << endl;
  }
}

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

using namespace std;

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

int main() {
  int nnn;
  cin >> nnn;
  for (int iii = 0; iii < nnn; ++iii) {
    string input;
    cin >> input;
    int prev = 0, cnt = 0;
    for (char c : input) {
      int i = c-'0';
      if (i == 0) {
	if (prev != 0) {
	  cout << chars[prev][(cnt-1) % chars[prev].size()];
	}
	prev = i;
	cnt = 0;
      } else {
	prev = i;
	++cnt;
      }
    }
    cout << endl;
  }
}

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

vector<char> Button[9];

void hoge(){

    Button[0].push_back('.');
    Button[0].push_back(',');
    Button[0].push_back('!');
    Button[0].push_back('?');
    Button[0].push_back(' ');
    string s="abcdefghijklmnopqrstuvwxyz";
    int k=0;
    for(int i=1; i<=8; i++){
        for(int j=0; j<(i==6||i==8? 4: 3); j++){
            Button[i].push_back(s[k]);
            k++;
        }
    }
}

int main(){

    hoge();

    int n;
    cin>> n;
    for(int i=0; i<n; i++){
        string s;
        cin>> s;
        char p='0';
        int k=0;
        for(int j=0; j<s.size(); j++){
            if(s[j]=='0'){
                if(p!='0'){
                    int mo=(p=='1'? 5: (p=='7'||p=='9'? 4: 3));
                    cout<< Button[p-'0'-1][(k-1+mo)%mo];
                }
                k=0;
            }else{
                k++;
            }
            p=s[j];
        }
        cout<< endl;
    }

    return 0;
}

C++: #include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;
int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		string key[]={".,!?, ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
		string input;
		cin>>input;
		stringstream b(input);
		int num=0,count=0;
		while(1){
			char c;
			if(b>>c)break;
			int input=atoi(c);
			if(input!=0){
				count++;
				num=input;
			}
			else {
				if(count!=0)
					count<<key[num-1][count%key[num-1].size()];
				num=0;count=0;
			}
		}
		cout<<endl;
	}
	return 0;
}