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>

using namespace std;

int main()
{
    string messages[9]= {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        string msg;
        string output = "";
        int count = 0;
        char buf;

        cin >> msg;

        for (int j = 0; j < (int)msg.size(); j++) {
            char c = msg[j];

            if (c == '0' && j != 0) {
                if (buf == '1') {
                    output += messages[0][(count-1) % 5];
                } else if (buf == '2') {
                    output += messages[1][(count-1) % 3];
                } else if (buf == '3') {
                    output += messages[2][(count-1) % 3];
                } else if (buf == '4') {
                    output += messages[3][(count-1) % 3];
                } else if (buf == '5') {
                    output += messages[4][(count-1) % 3];
                } else if (buf == '6') {
                    output += messages[5][(count-1) % 3];
                } else if (buf == '7') {
                    output += messages[6][(count-1) % 4];
                } else if (buf == '8') {
                    output += messages[7][(count-1) % 3];
                } else if (buf == '9') {
                    output += messages[8][(count-1) % 4];
                }
                count = 0;
                buf = '0';
            } else {
                count++;
                buf = msg[j];
            }
        }
        cout << output << endl;
    }

    return 0;
}

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

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

void solve() {
	string line;
	cin >> line;
	char pre;
	int count = -1;
	for (unsigned i = 0; i < line.size(); ++i) {
		if (line[i] == '0') {
			int key = pre - '0';
			if (key == 0) continue;
			int index = count % button[key].size();
			cout << button[key][index];
			count = -2;
		}
		count++;
		pre = line[i];
	}
	cout << endl;
}

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

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

using namespace std;

int main()
{
    string messages[9]= {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        string msg;
        string output = "";
        int count = 0;
        char prev = '0';

        cin >> msg;

        for (int j = 0; j < (int)msg.size(); j++) {
            char c = msg[j];

            if (c == '0' && j != 0) {
                if (prev == '1') {
                    output += messages[0][(count-1) % 5];
                } else if (prev == '2') {
                    output += messages[1][(count-1) % 3];
                } else if (prev == '3') {
                    output += messages[2][(count-1) % 3];
                } else if (prev == '4') {
                    output += messages[3][(count-1) % 3];
                } else if (prev == '5') {
                    output += messages[4][(count-1) % 3];
                } else if (prev == '6') {
                    output += messages[5][(count-1) % 3];
                } else if (prev == '7') {
                    output += messages[6][(count-1) % 4];
                } else if (prev == '8') {
                    output += messages[7][(count-1) % 3];
                } else if (prev == '9') {
                    output += messages[8][(count-1) % 4];
                }
                count = 0;
            } else {
                count++;
            }
            prev = msg[j];
        }
        cout << output << endl;
    }

    return 0;
}

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

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

int main(){
	
	int n ;
	string s ;
	
	cin >> n ;
	for( int i=0 ; i<n ; i++ ){
		cin >> s ;
		for( int j=0 ; j<s.size() ; j++ ){
			int cnt = 0 , p = 3 ;
			char a = s[j] ;
			if( a == '0' ) continue ;
			if( a == '1' ) p = 5 ;
			if( a == '6' || a == '8' ) p = 4 ;
			for( j+=1 ; j<s.size() ; j++ ){
				if( s[j] == a ) cnt++ ;
				if( s[j] == '0' ) break ;
			}
			cout << table[a-'0'-1][cnt%p] ;
		}
		cout << endl ;
	}
	
return 0 ;
}