Go: package main

import (
	"bytes"
	"fmt"
)

//Ktai has a keyboard and a state.
type Ktai struct {
	keyboard KeyBoard
	textBuf  *bytes.Buffer
}

// KeyBoard is type of a map.
type KeyBoard map[rune]string

// KEYBOARD that Ktai has
var KEYBOARD = KeyBoard{
	'0': "",
	'1': ".,!? ",
	'2': "abc",
	'3': "def",
	'4': "ghi",
	'5': "jkl",
	'6': "mno",
	'7': "pqrs",
	'8': "tuv",
	'9': "wxyz",
}

func main() {
	var N int
	fmt.Scanf("%d", &N)
	ktai := &Ktai{
		KEYBOARD, &bytes.Buffer{},
	}
	for i := 0; i < N; i++ {
		var numstr string
		fmt.Scanf("%s", &numstr)
		ktai.feed(numstr)
		ktai.print()
	}
}

func (ktai *Ktai) feed(str string) {
	var char *byte
	for _, v := range str {
		if v == '0' {
			if char != nil {
				ktai.textBuf.WriteByte(*char)
				char = nil
			}
			continue
		} else {
			runestring := ktai.keyboard[v]
			idx := ktai.indexOf(char, runestring)
			next := (idx + 1) % len(runestring)
			c := runestring[next]
			char = &c
		}
	}
}

func (ktai *Ktai) indexOf(ch *byte, str string) int {
	if ch == nil {
		return -1
	}
	r := rune(*ch)
	idx := -1
	for i, v := range str {
		if r == v {
			idx = i
			break
		}
	}
	return idx
}

func (ktai *Ktai) print() {
	fmt.Println(ktai.textBuf.String())
	ktai.textBuf.Reset()
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cmath>
#include<set>
#include<stack>

using namespace std;

int main()
{
    vector<vector<char> >ph;
    vector<char>c;
    ph.push_back(c);
    c.push_back('.');
    c.push_back(',');
    c.push_back('!');
    c.push_back('?');
    c.push_back(' ');
    ph.push_back(c);
    c.clear();
    
    char cc='a';
    while(cc!='p'){
        for(int i=0;i<3;i++){
            c.push_back(cc++);
        }
        ph.push_back(c);
        c.clear();
    }
    for(int i=0;i<4;i++){
        c.push_back(cc++);
    }
    ph.push_back(c);
    c.clear();
    for(int i=0;i<3;i++){
        c.push_back(cc++);
    }
    ph.push_back(c);
    c.clear();
    for(int i=0;i<4;i++){
        c.push_back(cc++);
    }
    ph.push_back(c);
    
    int n;
    cin>>n;
    while(n--){
        string s;
        cin>>s;
        char cu='#';
        int co=0;
        for(int i=0;i<s.length();i++){
            if(s[i]=='0'){
                if(cu=='#'){
                    continue;
                } else {
                    co--;
                    cout<<ph[cu-'0'][co%(ph[cu-'0'].size())];
                    cu='#';
                    co=0;
                }
            } else {
                co++;
                cu=s[i];
            }
        }
        cout<<endl;
    }
    //freopen("/Users/shitian/Desktop/gcj/gcj/A-large.in", "r", stdin);
    //freopen("/Users/shitian/Desktop/gcj/gcj/out.txt", "w", stdout);
//    int tcase;
//    cin>>tcase;
//    for(int tca=1;tca<=tcase;tca++){
//        cout<<"Case #"<<tca<<": ";
//
//    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    char code[][5] = {
        {0,0,0,0,0},
        {'.',',','!','?',' '},
        {97,98,99,0,0},
        {100,101,102,0,0},
        {103,104,105,0,0},
        {106,107,108,0,0},
        {109,110,111,0,0},
        {112,113,114,115,0},
        {116,117,118,0,0},
        {119,120,121,122,0}
    };
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string input;
        cin >> input;
        int num = 0;
        int index = 0;
        for (int j = 0; j < input.length(); ++j) {
            if (input[j] == '0') {
                cout << code[num][index];
                num = 0;
                index = 0;
            } else if (!index && !num) {
                num = input[j] - '0';
            } else {
                while(num) {
                    if (++index == 5) index = 0;
                    if (code[num][index]) break;
                }
            }
        }
        cout << endl;
    }
}

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

void bo(int,int);

void bo(int t,int m){
  if(t==1){
    if(m%5==1) cout<<".";
  else if(m%5==2) cout<<",";
  else if(m%5==3)cout<<"!";
  else if(m%5==4)  cout<<"?";
  else cout<<" ";
  }else if(t==2){
    if(m%3==1) cout<<"a";
    else if(m%3==2) cout<<"b";
    else cout<<"c";
  }else if(t==3){
    if(m%3==1) cout<<"d";
    else if(m%3==2) cout<<"e";
    else cout<<"f";
  }else if(t==4){
    if(m%3==1) cout<<"g";
    else if(m%3==2) cout<<"h";
    else cout<<"i";
  }else if(t==5){
    if(m%3==1) cout<<"j";
    else if(m%3==2) cout<<"k";
    else cout<<"l";
  }else if(t==6){
    if(m%3==1) cout<<"m";
    else if(m%3==2) cout<<"n";
    else cout<<"o";
  }else if(t==7){
    if(m%4==1) cout<<"p";
    else if(m%4==2) cout<<"q";
    else if(m%4==3) cout<<"r";
    else cout<<"s";
  }else if(t==8){
    if(m%3==1) cout<<"t";
    else if(m%3==2) cout<<"u";
    else cout<<"v";
  }else if(t==9){
    if(m%4==1) cout<<"w";
    else if(m%4==2) cout<<"x";
    else if(m%4==3) cout<<"y";
    else cout<<"z";
  }
}
		     
int main(){
  string str;
  int n;
  cin>>n;
  int cou=0;
  for(int i=0;i<n;i++){
  cin>>str;
  for(int j=0;j<str.size();j++){
    if( j>0 && str[j]=='0' ){
	bo(str[j-1]-'0',cou);
      cou=0;
      continue;
    }
    else if(str[j]!='0') cou++;
  }
  cout<<endl;
  }
  return 0;
}

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

using namespace std;

int main(void){
	int n; cin >> n;
	string dic[] ={" ", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	for(int _=0; _<n; _++){
		string str; cin >> str;
		int cnt = -1;
		char val = '0';
		for(int i=0; i<str.size(); i++){
			if(str[i] == '0'){
				if(val == '0') continue;
				if(val == '1') cnt%=5;
				else if(val == '7' || val == '9') cnt %= 4;
				else cnt %= 3;
				cout << dic[val-'0'][cnt];
				cnt = -1;
				val = '0';
			} else{
				cnt++;
				val = str[i];
			}
		}
		cout << endl;
	}
}

C++: #include<cstdio>
#include<cstring>

char map[10][10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

int main(void) {
    char in[2000];
    int n;
    scanf("%d",&n);
    while(~scanf("%s", in)) {
        char c;
        int pos=0;
        while(c=in[pos]) {
            int i=0;
            while(c==in[pos+(++i)]);
            if(c-'0') printf("%c", map[c-'0'][(i-1)%strlen(map[c-'0'])]);
            pos += i;
        }
        printf("\n");
    }
    return 0;
}