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 <bits/stdc++.h>
using namespace std;

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

int main(){
    int N;
    for(scanf("%d", &N); N--;){
        char mes[1280];
        scanf(" %s", mes);
        int len = strlen(mes);
        int prv = 0, count = 0;
        for(int i = 0; i < len; i++){
            if(mes[i] == '0'){
                if(prv > 0){
                    --prv;
                    printf("%c", bt[prv][--count % strlen(bt[prv])]);
                }
                count = 0;
            }else{
                count++;
            }
            prv = mes[i] - '0';
        }
        if(prv > 0){
            --prv;
            printf("%c", bt[prv][--count % strlen(bt[prv])]);
        }
        puts("");
    }
    return 0;
}

C++: #include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <stack>
#include <set>
#include <vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;


int main() {
  int n_cases; cin >> n_cases;
  while (n_cases--) {
    string s; cin >> s;
    vi ch, num;
    rep(i, s.size()) {
      int c = s[i] - '0';
      if (ch.size() != 0 && ch.back() == c) {
        num[num.size() - 1]++;
      }
      else {
        ch.pb(c);
        num.pb(0);
      }
    }

    string table[] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    rep(i, ch.size()) {
      if (ch[i] == 0) continue;
      cout << table[ch[i] - 1][num[i] % table[ch[i] - 1].size()];
    }

    cout << endl;
  }
  
  return 0;
}

C++: //{{{
#define DEF
#ifdef DEF
#include <iostream>
#include <algorithm>
#include <functional>
#include <stack>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <cstring>
#include <cmath>
#include <set>
#include <deque>

//-----------------------------------------------------
#define mrepp(i,n,x)  for(int i = n-1; i >= x; i--)
#define mrep(i,n) mrepp(i,n,0)
#define repp(i,x,n)  for(int i = x; i < n; i++)
#define rep(i,n) repp(i,0,n)

using namespace std;
typedef pair<int, int> Pii;
typedef long long int llint;

template<typename T>
void display(T &t, int start_x, int start_y, int end_x, int end_y) {
	cout << "===================" << endl;
	repp(i,start_y,end_y) {
		repp(j,start_x,end_x)
			printf("%4d:", t[i][j]);
		cout << endl;
	}
	cout << "===================" << endl;
}

//-----------------------------------------------------
#endif
//}}}

char moji[10][6] = {
		{},
		{5,'.',',','!','?',' '},
		{3,'a','b','c'},
		{3,'d','e','f'},
		{3,'g','h','i'},
		{3,'j','k','l'},
		{3,'m','n','o'},
		{4,'p','q','r','s'},
		{3,'t','u','v'},
		{4,'w','x','y','z'},
};

void solve() {

}

int main(void) {

	int n;
	cin >> n;
	rep(g,n){
		string s;
		cin >> s;
		int flag = 0;
		int count = -1;
		int a;
		rep(h,(int)s.size()){
			if(s[h]=='0' && !flag)continue;
			if(s[h]=='0' && flag){
				flag = 0;
				count = count % moji[a][0] + 1;
				cout << moji[a][count] << flush;
				count = -1;
			}
			else{
				a = s[h]-'0';
				count++;
				flag = 1;
			}
		}
		cout << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main(){
  int n,i,j,k,p;
  string str;
  cin>>n;
  for(j=0;j<n;j++){
    cin >> str;
    p=0;
    char c;
    for(i=0;i<str.size();i++){
      if(str[i]=='0'){
	if(p!=0){
	  if(c=='1'){
	    if(p%5==1) cout << '.';
	    if(p%5==2) cout << ',';
	    if(p%5==3) cout << '!';
	    if(p%5==4) cout << '?';
	    if(p%5==4) cout << ' ';
	  }
	  if(c=='2'){
	    printf("%c", ('a'+(p-1)%3));
	  }
	  if(c=='3'){
	    printf("%c", ('d'+(p-1)%3));
	  }
	  if(c=='4'){
	    printf("%c", ('g'+(p-1)%3));
	  }
	  if(c=='5'){
	    printf("%c", ('j'+(p-1)%3));
	  }
	  if(c=='6'){
	   printf("%c", ('m'+(p-1)%3));
	  }
	  if(c=='7'){
	    printf("%c", ('p'+(p-1)%4));
	  }
	  if(c=='8'){
	    printf("%c", ('t'+(p-1)%3));
	  }
	  if(c=='9'){
	    printf("%c", ('w'+(p-1)%4));
	  }
	}
	p=0;
      }else{
	c=str[i];
	p++;
      }
      
    }
    cout << endl;
  }
  return 0;
}

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

char mes(char c){
    int n = c -'0';
    if(n==2)return 'a';
    else if(n==3)return 'd';
    else if(n==4)return 'g';
    else if(n==5)return 'j';
    else if(n==6)return 'm';
    else if(n==7)return 'p';
    else if(n==8)return 't';
    else return 'w';
}


int main(){
    long long n;
    cin >> n;
    for(int i=0;i<n;i++){
        string str;
        cin >> str;
        int cou = 0;    
        for(int j=0;j<str.size();j++){
           if(str[j]=='0' && str[j-1]!='0' && j!=0){
                    cou--;
                    if(str[j-1]!='1'){
                        char a = mes(str[j-1]);
                        if(str[j-1]=='7'||str[j-1]=='9')printf("%c",a + (cou)%4);
                        else printf("%c",a+cou%3);
                    }else{
                       cou%=5;
                        if(!cou)cout << ".";
                        else if(cou==1)cout << ",";
                        else if(cou==2)cout << "!";
                        else if(cou==3)cout << "?";
                        else cout << " ";
                    }
                cou = 0;
           }else if(str[j]!='0'){
               cou++;
           }
        }
        cout << endl;
    }
}