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 <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

string solve(string s){
    int count=0;
    string ans;
    char keep;
    string keeps;
    char c;
    for(int i=0;i<s.size();i++){
        // char k=s[i];
        if(s[i]!='0'){
            count++;
            c=s[i];
        }
        else{
                if(c== '2'){
                    if(count%3==1)ans.append(1,'a');
                    else if(count%3==2)ans.append(1,'b');
                    else ans.append(1,'c');
                }
                else if(c== '3'){
                    if(count%3==1)ans.append(1,'d');
                    else if(count%3==2)ans.append(1,'e');
                    else ans.append(1,'f');
                }
                else if(c== '4'){
                    if(count%3==1)ans.append(1,'g');
                    else if(count%3==2)ans.append(1,'h');
                    else ans.append(1,'i');
                }
                else if(c== '5'){
                    if(count%3==1)ans.append(1,'j');
                    else if(count%3==2)ans.append(1,'k');
                    else ans.append(1,'l');
                }
                else if(c== '6'){
                    if(count%3==1)ans.append(1,'m');
                    else if(count%3==2)ans.append(1,'n');
                    else ans.append(1,'o');
                }
                else if(c== '7'){
                    if(count%4==1)ans.append(1,'p');
                    else if(count%4==2)ans.append(1,'q');
                    else if(count%4==3)ans.append(1,'r');
                    else ans.append(1,'s');
                }
                else if(c== '8'){
                    if(count%3==1)ans.append(1,'t');
                    else if(count%3==2)ans.append(1,'u');
                    else ans.append(1,'v');
                }
                else if(c== '9'){
                    if(count%4==1)ans.append(1,'w');
                    else if(count%4==2)ans.append(1,'x');
                    else if(count%4==3)ans.append(1,'y');
                    else ans.append(1,'z');
                }
                else if(c== '1')
                    if(count%4==1)ans.append(1,'.');
                    else if(count%4==2)ans.append(1,',');
                    else if(count%4==3)ans.append(1,'!');
                    else ans.append(1,'?');
                    break;
            count=0;
        }
    }
    // cout << ans << "%%%%%%%%%%%%%%%%"<<endl;
    return ans;
}

int main(int argc, char const *argv[]) {
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    vector<string>ans;
    for(int i=0;i<n;i++){
        cin >> s;
        ans.push_back(solve(s));
    }
    for(int i=0;i<n;i++){
        cout << ans[i]<<endl;
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	char a[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 n,b=0,c=0,d=0;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;b=d=c=0;
		char ss[100];
			for(int j=0;j<s.size();j++){
				if(s[j]=='0'&&c>0){
					if(s[j-1]=='1')d=(c-1)%5;
					else if(s[j-1]=='6'||s[j-1]=='8')d=(c-1)%4;
					else d=(c-1)%3;
					cout<<a[(int)(s[j-1]-'0')-1][d];
				c=0;
				}
				else c++;
				}
				cout<<endl;
	}
	return 0;
}

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

using namespace std;

int Atoi(const char);

int main(){
  int i, j, n, x, y;
  char c; 
  string str, _str, data[9];

  data[0] = ".,!? ";
  data[1] = "abc";
  data[2] = "def";
  data[3] = "ghi";
  data[4] = "jkl";
  data[5] = "mno";
  data[6] = "pqrs";
  data[7] = "tuv";
  data[8] = "wxyz";

  cin >> n;

  for(i=0; i<n; ++i){
    cin >> str;

    for(j=0, c='0'; j<str.size(); ++j){
      if(c != str[j]){
	if(c == '0'){
	  y = 0;
	  c = str[j];
	}else{
	  x = Atoi(c)-1;
	  y %= data[x].size();
	  _str.push_back(data[x][y]);
	  c = '0';
	}
      }else if(c != '0'){
	++y;
      }
    }

    cout << _str << endl;
    _str.clear();
  }
  return 0;
}

int Atoi(const char c){
  int x;
  x = c - 48;
  return x;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a,d[9];
	d[0]=".,!? ",d[1]="abc",d[2]="def",d[3]="ghi",d[4]="jkl";
	d[5]="mno",d[6]="pqrs",d[7]="tuv",d[8]="wxyz";
	for(int i=0;i<n;i++){
		cin>>a;
		int count=-1;
		for(int j=0;j<a.size();j++){
			if(j!=0){
			if(a[j]=='0'&&a[j-1]!='0'){
				cout<<d[a[j-1]-'1'][count];
			    count=-1;
			}
			}
			if(a[j]!='0')
			    count++;
			if(a[j]=='1')
				count%=5;
			else if(a[j]=='7'||a[j]=='9')
				count%=4;
			else
				count%=3;
		}
		cout<<endl;
	}
    return 0;
}

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

string order;
vector<int> num;
vector<char> word;
int n;
char button[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 main()
{
  int but = 0,push = 0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> order;
    for(int j=0;j<order.size();j++){
      num.push_back((int)(order[j]-'0'));
    }
    for(int j=0;j<num.size();j++){
      if(1<=num[j] && num[j]<=9){
	if(but==0){
	  but = num[j];
	}else{
	  push++;
	}
      }else if(num[j]==0){
	if(but==0){
	  continue;
	}
	
	const int mod = (but == 1 ? 5 : but == 7 || but == 9 ? 4 : 3);

	word.push_back(button[but-1][push%mod]);
	push = 0;
	but = 0;
      }
    }
    
    for(int k=0;k<word.size();k++){
      cout << word[k];
    }
    cout << endl;
    
    word.clear();
    num.clear();
  }
  
  return 0;
  
}

C++: #include <algorithm>
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1

using namespace std;

int main() {
  int n, pre, cur, count;
  string s;
  string org[] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
  vector<string> button(org, org+9);
  cin >> n;
  while (n--) {
    cin >> s;
    pre = 0;
    for (int i = 0; i < s.length(); i++) {
      cur = (int)(s[i]-'0');
      if (pre == 0) {
        if (cur != 0) {
          pre = cur;
        }
      } else {
        if (cur == 0) {
          cout << button[pre-1][count];
          pre = 0;
          count = 0;
        } else {
          count = (count+1)%button[pre-1].length();
        }
      }
    }
    cout << el;
  }
}