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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(s) begin(s),end(s)
#define VIEW(dat) for(auto v : dat){cout<<v<<endl;}
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(a,b) make_pair((a),(b))


const int INF=1<<24;

using namespace std;

string valOf(int n){ stringstream ss;ss<<n;return ss.str();}
int    valOf(string s){return atoi(s.c_str());}
int    valOf(char s){return (unsigned int)(s - '0');}

string deco(int id,int n){
	switch(id){
		case 1:
		switch(n){
			case 0:	return ".";
			case 1:	return ",";
			case 2:	return "!";
			case 3:	return "?";
			case 4:	return " ";	
		}break;
		case 2:
		switch(n){
			case 0:	return "a";
			case 1:	return "b";
			case 2:	return "c";
		}break;	
		case 3:
		switch(n){
			case 0:	return "d";
			case 1:	return "e";
			case 2:	return "f";
		}break;	
		case 4:
		switch(n){
			case 0:	return "g";
			case 1:	return "h";
			case 2:	return "i";
		}break;	
		case 5:
		switch(n){
			case 0:	return "j";
			case 1:	return "k";
			case 2:	return "l";
		}break;	
		case 6:
		switch(n){
			case 0:	return "m";
			case 1:	return "n";
			case 2:	return "o";
		}break;	
		case 7:
		switch(n){
			case 0:	return "p";
			case 1:	return "q";
			case 2:	return "r";
			case 3:	return "s";
		}break;		
		case 8:
		switch(n){
			case 0:	return "t";
			case 1:	return "u";
			case 2:	return "v";
		}break;	
		case 9:
		switch(n){
			case 0:	return "w";
			case 1:	return "x";
			/*???????????????????????????????*/
			case 2:	return "z";
			case 3:	return "y";
			/*???????????????????????????????*/
		}break;	
	}
	return "";
}



string solve(string s){
	int nn=-1;
	string rls="";
	vector<int> num(10);
	rep(i,9){
		num[i]=0;
	}
	rep(i,s.size()){
		if(!valOf(s[i])){
			rls+=deco(nn,num[nn]);
			rep(i,9){
				num[i]=0;
			}
			nn=-1;
		}
		switch(valOf(s[i])){
			case 1:
				if(nn==1){
			    	num[nn]++;
			    }nn=1;
				if(num[nn]>4){
					num[nn]=0;
				}
				break;
			case 2:
			   if(nn==2){
			    	num[nn]++;
			    } nn=2;
				if(num[nn]>2){
					num[nn]=0;
				}
				break;
			case 3:
				if(nn==3){
			    	num[nn]++;
			    }nn=3;
				if(num[nn]>2){
					num[nn]=0;
				}
				break;
			case 4:
				if(nn==4){
			    	num[nn]++;
			    }nn=4;
				if(num[nn]>2){
					num[nn]=0;
				}
				break;
			case 5:
				if(nn==5){
			    	num[nn]++;
			    }nn=5;
				if(num[nn]>2){
					num[nn]=0;
				}
				break;
			case 6:
				if(nn==6){
			    	num[nn]++;
			    }nn=6;
				if(num[nn]>2){
					num[nn]=0;
				}
				break;
			case 7:
				if(nn==7){
			    	num[nn]++;
			    }nn=7;
				if(num[nn]>3){
					num[nn]=0;
				}
				break;
			case 8:
				if(nn==8){
			    	num[nn]++;
			    }nn=8;
				if(num[nn]>2){
					num[nn]=0;
				}
				break;
			case 9:
				if(nn==9){
			    	num[nn]++;
			    }nn=9;
				if(num[nn]>3){
					num[nn]=0;
				}
				break;
		}
	}
	return rls;
}
	

int main(){
	
	int  n;
	
	string in;
	
	//ifstream cin("in.txt");
	
	cin>>n;
	while(n--){
		cin>>in;
		cout<<solve(in)<<endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
#include <set>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;
int main()
{

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

	int n;

	cin >> n;
	for (int i = n; i > 0; i--){
		string str, tmp = "";
		cin >> str;

		int cnt = 0, temp = 0;
		string s = "";
		for (int i = 0; i < str.size(); i++){
			if (str[i] == '0'){
				if (!cnt) continue;
				tmp += key[temp][cnt - 1];
				temp = cnt = 0;
			}
			else{
				temp = str[i] - '0';
				if ((cnt>2) && (temp == 2 || temp == 3 || temp == 4 || temp == 5 || temp == 6 || temp == 8)) cnt -= 3;
				else if ((cnt>3) && (temp == 7 || temp == 9)) cnt -= 4;
				else if ((cnt>4) && temp == 1) cnt -= 5;
				cnt++;
			}
		}
		cout << tmp << endl;
	}
	return 0;
}

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


int X;
char s[1050];

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


int main(){

  cin >> X;
  while(X){

    cin >> s;

    int i = 0;
    char pre;
    int n;

    for(i = 0; i < strlen(s); i++){
      n = 1;
     
      pre = s[i];
      if(pre == '0') continue;
      while(pre == s[i+1] && i < strlen(s)){
	n++;
	i++;
      }
      int x = atoi(&pre);
   
      cout <<  b[x-1][(n-1) % b[x-1].length()];
    }
    cout << endl;
    X--;
  }
  return 0;
}

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

using namespace std;

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

int main() {
?? int nnn;
?? cin >> nnn;
?? for (int iii = 0; iii < nnn; ++iii) {
?? ?? string input;
?? ?? cin >> input;
?? ?? int prev = 0, cnt = 0;
?? ?? for (char c : input) {
?? ?? ?? int d = c-'0';
?? ?? ?? if (d == 0) {
?? ?? ?? ?? if (prev != 0) {
?? ?? ?? ?? ??cout << chars[prev][(cnt-1) % chars[prev].size()];
?? ?? ?? ?? }
?? ?? ?? ?? cnt = 0;
?? ?? ?? } else {
?? ?? ?? ?? ++cnt;
?? ?? ?? }
?? ?? ?? prev = d;
?? ?? }
?? ?? cout << endl;
?? }
}