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 <algorithm>
#include <cassert>
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;

    auto split = [](const string& s, char delimiter) {
        stringstream ss;
        ss << s;
        string t;
        vector<string> r;
        while (getline(ss, t, delimiter)) {
            if (!t.empty()) {
                r.push_back(t);
            }
        }
        return r;
    };

    auto encode = [](const string& s) {
        const auto c = s[0];
        const auto len = s.size() - 1;
        if (c == '1') {
            switch (len % 5) {
            case 0:
                return '.';
            case 1:
                return ',';
            case 2:
                return '!';
            case 3:
                return '?';
            case 4:
                return ' ';
            }
        }
        else if (c == '2') {
            switch (len % 3) {
            case 0:
                return 'a';
            case 1:
                return 'b';
            case 2:
                return 'c';
            }
        }
        else if (c == '3') {
            switch (len % 3) {
            case 0:
                return 'd';
            case 1:
                return 'e';
            case 2:
                return 'f';
            }
        }
        else if (c == '4') {
            switch (len % 3) {
            case 0:
                return 'g';
            case 1:
                return 'h';
            case 2:
                return 'i';
            }
        }
        else if (c == '5') {
            switch (len % 3) {
            case 0:
                return 'j';
            case 1:
                return 'k';
            case 2:
                return 'l';
            }
        }
        else if (c == '6') {
            switch (len % 3) {
            case 0:
                return 'm';
            case 1:
                return 'n';
            case 2:
                return 'o';
            }
        }
        else if (c == '7') {
            switch (len % 4) {
            case 0:
                return 'p';
            case 1:
                return 'q';
            case 2:
                return 'r';
            case 3:
                return 's';
            }
        }
        else if (c == '8') {
            switch (len % 3) {
            case 0:
                return 't';
            case 1:
                return 'u';
            case 2:
                return 'v';
            }
        }
        else if (c == '9') {
            switch (len % 4) {
            case 0:
                return 'w';
            case 1:
                return 'x';
            case 2:
                return 'y';
            case 3:
                return 'z';
            }
        }
        assert(false);
    };

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

        auto r = split(s, '0');
        string rr;
        transform(begin(r), end(r), back_inserter(rr), encode);

        cout << rr << endl;
    }
}

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

int main(){
  int n;
  string bottan[]={
    "",
    ".,!? ", // 1
    "abc", // 2
    "def", // 3
    "ghi", // 4
    "jkl", // 5
    "mno", // 6
    "pqrs", // 7
    "tuv", // 8
    "wxyz", // 9
  };
  int cnt[] = {5,3,3,3,3,3,4,3,4};
  
  cin >> n;
  while(n--){
    string str; cin >> str;
    int len = str.size();
    int cnt1=0,cnt2=0;
    for(int i=0;i<len;i++){
      if(str[i] == '0'){
	if(cnt1 != 0){
	  if(cnt2%cnt[cnt1] == 0){
	    cout << bottan[cnt1][cnt[cnt1]-1];
	  }
	  else {
	    cout << bottan[cnt1][cnt2%cnt[cnt1]-1];
	  }
	}
	cnt1 = 0; cnt2 = 0;
      }
      else {
	if(cnt1 == 0){
	  cnt1 = str[i] - '0';
	  cnt2++;
	}
	else {
	  cnt2++;
	}
      }
    }
    cout << endl;
  }
}

C++: #include <stdio.h>
#include <string.h>
#define INF 100000
int main(void)
{
    char phone[10][6] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    char message[3000];
    int buf;
    int t;
    int i, j;
     
    scanf("%d", &t);
     
    while (t--){
        scanf("%s", message);
        getchar();
         
        i = 0;
        while (message[i] != '\0'){
            buf = INF;
            j = 0;
            while ('0' <= message[i] && message[i] <= '9' && message[i] != '0' && message[i] != '\0'){
                buf = phone[message[i] - '0'][j % strlen(phone[message[i] - '0'])];
                j++;
                if (message[i + 1] != '0' && i + 1 < strlen(message) && message[i] != message[i + 1]){
                    j = 0;
                }
                i++;
            }
            if (!('0' <= message[i] && message[i] <= '9') || message[i] != '0'){
                buf = INF;
            }
            if (buf != INF){
                printf("%c", buf);
            }
            if (message[i] == '\0'){
                break;
            }
            i++;
        }
        printf("\n");
    }
     
    return (0);
}

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

using namespace std;

typedef long long ll;

#define int long long

int N;
int last, cnt;

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

string Output(int n)
{
	string res;
	if (n == 0)
	{
		if (cnt > 0) res.push_back(s[last - 1][--cnt % s[last - 1].size()]);
		cnt = 0;
		return res;
	}
	last = n;
	cnt++;
	return "";
}

signed main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		string S, ans;
		cin >> S;
		for (int j = 0; j < S.size(); j++)
		{
			ans += Output(S[j] - '0');
		}
		cout << ans << endl;
	}
	return 0;
}