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 <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

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

int main(){
    int T,i;
    string in;

    cin >> T;
    while( T-- ){
        cin >> in;

        int cnt = 0, num = -1;
        rep(i,in.length()){
            if( in[i] == '0' ){
                if( num != -1 ){
                    putchar(keitai[num][(cnt-1)%strlen(keitai[num])]);
                }
                cnt = 0, num = -1;
            }
            else{
                num = in[i] - '0';
                cnt++;
            }
        }
        puts("");
    }
    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'},{'i','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]); //cout << button[but-1][push%3] << endl;
	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<iostream>
#include<string>
#include<vector>
using namespace std;
vector<pair<int,int> > vpii(80);
string num;
void print(int s,int m,int f){
  switch(f-48){
  case 1:switch(s%5){
    case 1:cout<<'.';break; case 2:cout<<',';break; case 3:cout<<'!';break;case 4:cout<<'?';break; case 5:cout<<" ";break;}break;
  case 2:switch(s%3){
    case 1:cout<<'a';break; case 2:cout<<'b';break; case 3:cout<<'c';break;}break;
  case 3:switch(s%3){
    case 1:cout<<'d';break;case 2:cout<<'e';break;case 3:cout<<'f';break;}break;
  case 4:switch(s%3){
    case 1:cout<<'g';break;case 2:cout<<'h';break;case 3:cout<<'i';break;} break;
  case 5:switch(s%3){
    case 1:cout<<'j';break;case 2:cout<<'k';break;case 3:cout<<'l';break;} break;
  case 6:switch(s%3){
    case 1:cout<<'m';break;case 2:cout<<'n';break;case 3:cout<<'o';break;} break;
  case 7:switch(s%4){
    case 1:cout<<'p';break;case 2:cout<<'q';break;case 3:cout<<'r';break;case 4:cout<<'s';break;} break;
  case 8:switch(s%3){
    case 1:cout<<'t';break;case 2:cout<<'u';break;case 3:cout<<'v';break;}break; 
  case 9:switch(s%4){
    case 1:cout<<'w';break;case 2:cout<<'x';break;case 3:cout<<'y';break;case 4:cout<<'z';break;}break;
  default :break; 
  }
}
void dfs(int m,int d,int w,char f){
  if(w==d){
    print(d,m,f);
    return;
  }
  dfs(m,d,w+1,f);
  return;
}
int main(){
  int k=0,l=0,n;
  cin >> n;
  for(int q=0;q<n;q++){
    l=0;
    cin >> num;
    int a;
    for(int i=0;i<num.size();i++){
      if(i==0)
	a=num[0];
      k++;
      if(i!=0&&num[i]=='0' &&num[i-1]=='0'){
	k=0;
	continue;
      }
      if(num[i]!='0')
	a=num[i];
      if(num[i]=='0'){
	vpii[l]=make_pair(a,k-1);
	l++;
	k=0;
      }
    }
    for(int j=0;j<l;j++){
      int w=0;
      dfs(j,vpii[j].second,w,vpii[j].first);
    }
    cout<<endl;
  }
  return 0;
}

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

int main() {
	int T;
	string S;
	vector<char> C[10];
	C[1] = { '.', ',', '!', '?', ' ' };
	for (int i = 2; i <= 7; i++) {
		for (int j = 0; j < 3; j++) C[i].push_back((char)('a' + (i - 2) * 3 + j));
	}
	C[7].push_back('s');
	C[8] = { 't', 'u', 'v' }, C[9] = { 'w', 'x', 'y', 'z' };
	cin >> T;
	for (int t = 0; t < T; t++) {
		cin >> S;
		int X = -1, Y = -1;
		for (int i = 0; i < S.size(); i++) {
			if (S[i] == '0') {
				if (X != -1) {
					cout << C[X][Y % C[X].size()];
				}
				X = -1, Y = -1;
			}
			else {
				if (S[i] - '0' == X) Y++;
				else X = S[i] - '0', Y = 0;
			}
		}
		cout << endl;
	}
}

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

int main() {

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


  int n;
  cin >> n;
  string str;
  for(int j=0;j<n;j++){
    cin >> str;
    int cnt = -1;
    int ima;
    for(int i=0;i<str.size();i++){
      if(cnt == -1 && str[i] == '0') continue;
      if(str[i] == '0'){
	cout <<key[ima][cnt%key[ima].size()];
	cnt = -1;
      }
      else{
	ima = str[i]-'0';
	cnt++;
      }   
    }
    cout << endl;
    
  }

    return 0;
}

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

int N;
char phone[9][6] = {".,!? ","abc","def","ghi","jkl", "mno", "pqrs", "tuv","wxyz"};

int main(){
  cin >> N;
  
  for(int i=0; i<N; ++i){
    char input[1025];
    cin >> input;
    char old = '0';
    int count = 0;
    for(int j=0; input[j] != '\0'; ++j){
      if(input[j] == '0'){
        if(old != '0'){
          if('2' <= old && old <= '6' || old == '8'){
            putchar(phone[old-'1'][(count-1)%3]);
          }
          else if(old == '1'){
            putchar(phone[old-'1'][(count-1)%5]);
          }
          else{
            putchar(phone[old-'1'][(count-1)%4]);
          }
        }
        old = input[j];
        count = 0;
      }else{
        old = input[j];
        count++;
      }
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;

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

void solve(void) {
  string s;
  cin >> s;

  string ans = "";
  int l = 0;
  while (l < s.size()) {
    while (l < s.size() && s[l] == '0') l++;
    if (l == s.size()) break;

    int cnt = 0, p = s[l] - '0';
    while (l < s.size() && s[l] != '0') l++, cnt++;
    if (l == s.size()) break;    
    
    ans += b[p][(cnt - 1) % b[p].size()];
  }

  cout << ans << endl;
}

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

  for (int i = 0; i < n; i++) {
    solve();
  }

  return 0;
}