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++: #define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int INF=1000000;
char fi[101][101];
int d[21][21];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int N,M;
int sx,sy;
int gx,gy;
int w,h;
int ans;

int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003

int dp[353][353]={0};
int bow[353][353]={0};


int main(){
	
	string s;
	int n;
	while(n>0){
		cin>>s;
		vector<string> p(10);
		p[1]=".,!? ";
		p[2]="abc";
		p[3]="def";
		p[4]="ghi";
		p[5]="jkl";
		p[6]="mno";
		p[7]="pqrs";
		p[8]="tuv";
		p[9]="wxyz";
		bool f=false;
		char c='0';
		int count=0;
		string a="";
		rep(i,s.size()){
			if(s[i]=='0'){
				if(f){
				if(c=='1'){
					count=(count-1)%5;
				}
				else if(c=='7'||c=='9'){
					count=(count-1)%4;
				}
				else{
					count=(count-1)%3;
				}
				a+=p[c-'0'][count];
				f=false;
				count=0;
				c='0';
				}
			}
			else{
				f=true;
				if(c!=s[i]){
					c=s[i];
					count=1;
				}
				else
					count++;
				
			}
			
		}
		cout<<a<<endl;
		n--;
	}
	
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<queue>	

using namespace std;

namespace MyLib {
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
}

using namespace MyLib;


int main() {
	string r;
	int n;
	cin >> n;
	REP(x,n){
		cin >> r;
		string s = "";
		int co = 0;
		string buf = "";
		int num = 0;
		REP(i, r.size())
			if (r[i] == '0') {
				if (num == 0)
					continue;
				if (num == 1)
					if (co % 5 == 1)
						buf = ".";
					else if (co % 5 == 2)
						buf = ",";
					else if (co % 5 == 3)
						buf = "!";
					else if (co % 5 == 4)
						buf = "?";
					else
						buf = ' ';
				else if (2 <= num&& num<= 6)
					buf = 'a' + (num - 2) * 3 + (co + 2) % 3;
				else if (num == 7)
					buf = 'p' + (co + 3) % 4;
				else if (num == 8) 
					buf = 't' + (co + 2) % 3;
				else {
					buf = 'w' + (co + 3) % 4;
				}
				s = s + buf;
				co = 0;
				num = 0;

			}
			else {
				num = (r[i] - '0');
				co++;
			}
			cout << s << endl;
	}

	return 0;

}

C++: #include<iostream>

using namespace std;

string str;

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

void solve() {
    cin>>str;
    char c = '\0';
    int cnt=-1;
    int num=0;

    for(int i=0;i<str.size();i++) {
        
        if(str[i]=='0') {
            if(cnt==-1) c='\0';
            else c=keys[num-1][cnt];
            cout<<(c);
            c='\0';
            cnt=-1;
            num=0;
        }
        else {
            num=str[i]-'0';
            cnt++;
            cnt%=keys[num-1].size();            
        }
    }
    cout<<endl;
}

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

    return 0;
}

C++: #include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

string s;

vector<vector<char> > b{
  vector<char>{},
  vector<char>{'.',',','!','?',' '},
  vector<char>{'a','b','c'},
  vector<char>{'d','e','f'},
  vector<char>{'g','h','i'},
  vector<char>{'j','k','l'},
  vector<char>{'m','n','o'},
  vector<char>{'p','q','r','s'},
  vector<char>{'t','u','v'},
  vector<char>{'w','x','y','z'},
};
int main(){ _;
  int n;cin>>n;
  REP(i,n){
    cin>>s;
    int last=0;
    int count=0;
    for(int j=0;j<(int)s.size();j++){
      if(last==0){
	count=0;
      }else if(s[j]=='0'){
	cout<<b[last][count%(int)b[last].size()];
      }else{
	count++;
      }
      last=(s[j]-'0');
    }
    cout<<endl;
  }
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

string keitai[]{".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main(){
	string s;
	while(cin>>s){
		int cnt=0;
		string ans;
		rep(i,s.size()){
			if(s[i]=='0'){
				if(cnt)ans+=keitai[s[i-1]-'1'][(cnt-1)%keitai[s[i-1]-'1'].size()];
				cnt=0;
			}
			if(i&&s[i-1]!=s[i])cnt=0;
			else cnt++;
		}
		cout<<ans<<endl;
	}
}

C++: #include <iostream>
#include <cstring>
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 <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string str,one=".,!? ",ans,seven="pqrswxyz";
		cin>>str;
		for(int j=0,co=0,num=0;j<=str.size();j++){
			if(num==str[j]-'0')co++;
			else{
				if(num==1)ans+=one[co%5];
				else if(num==7||num==9)ans+=seven[co%4+num/9*4];
				else if(num==8)ans+=co%3+'t';
				else if(num>1)ans+=co%3+'a'+3*(num-2);
				co=0;
				num=str[j]-'0';
			}
		}
		cout<<ans<<endl;
	}
}