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<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    char ans[][10] = {
        {NULL},
        {'.',',','!','?',' '},
        {'a','b','c'},
        {'d','e','f'},
        {'g','h','i'},
        {'j','k','l'},
        {'m','n','o'},
        {'p','q','r','s'},
        {'t','u','v'},
        {'w','x','y','z'}
    };
    ll n; cin >> n;
    rep(i,n){
        string s(100000,0);
        cin >> s;
        int temp = 0;
        int counter =-1 ;
        for(int k = 0;k<(int)s.size();k++){
            int now = int(s[k]-48);
            if(k == 0){temp = now;counter++;}
            else if(now != 0){
                temp = now;counter++;}
            if(now == 0){
                if(temp  == 9 || temp == 7)
                    counter%=4;
                else if(temp != 1&& temp != 7 && temp!= 9)
                    counter%=3;
                else if(temp == 1)
                    counter %=5;
                cout << ans[temp][counter];
                temp = 0;counter =-1;;
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include <stdio.h>

int main(){
    int m,i,j,k,x[77],p,q,r;
    char str[1024];
    scanf("%d",&m);
    for (k=0;k<m;k++){
        scanf("%s",str);
        i=0;
        j=1;
        while(1){
            if (str[i]=='\n') break;
            if (str[i]==0) {
                if (i>0&&str[i-1]!=0){
                    x[j]=i;
                    j++;
                }
            }
            i++;
            
        }
        x[0]=0;
        for (i=0;i<=j;i++) {
            p=x[i+1]-x[i]-1;
            q=p%3;
            r=p%4;
            if (str[x[i]+1]==1) {
                if (r==0) printf("?");
                if (r==1) printf(".");
                if (r==2) printf(",");
                if (r==3) printf("!");
            }
            if (str[x[i]+1]==2) {
                if (q==1) printf("a");
                if (q==2) printf("b");
                if (q==0) printf("c");
            }
            if (str[x[i]+1]==3) {
                if (q==1) printf("d");
                if (q==2) printf("e");
                if (q==0) printf("f");
            }
            if (str[x[i]+1]==4) {
                if (q==1) printf("g");
                if (q==2) printf("h");
                if (q==0) printf("i");
            }
            if (str[x[i]+1]==5) {
                if (q==1) printf("j");
                if (q==2) printf("k");
                if (q==0) printf("l");
            }
            if (str[x[i]+1]==6) {
                if (q==1) printf("m");
                if (q==2) printf("n");
                if (q==0) printf("o");
            }
            if (str[x[i]+1]==7) {
                if (r==1) printf("p");
                if (r==2) printf("q");
                if (r==3) printf("r");
                if (r==0) printf("s");
            }
            if (str[x[i]+1]==8) {
                if (q==1) printf("t");
                if (q==2) printf("u");
                if (q==0) printf("v");
            }
            if (str[x[i]+1]==9) {
                if (r==1) printf("w");
                if (r==2) printf("x");
                if (r==3) printf("y");
                if (r==0) printf("z");
            }
            
        
        }
    }
    return 0;
    
}

C++: #include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  /*
  char a1[5] = {'.',',','!','?',' '};
  char a2[3] = {'a','b','c'};
  char a3[3] = {'d','e','f'};
  char a4[3] = {'g','h','i'};
  char a5[3] = {'j','k','l'};
  char a6[3] = {'m','n','o'};
  char a7[4] = {'p','q','r','s'};
  char a8[3] = {'t','u','v'};
  char a9[4] = {'w','x','y','z'};
  */
  /*
  string a1=".,!? ";
  string a2="abc";
  string a3="def";
  string a4="ghi";
  string a5="jkl";
  string a6="mno";
  string a7="pqrs";
  string a8="tuv";
  string a9="wxyz";
 */
 string a[9] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
 //for(int i=0; i<9; i++) cout << a[i] << " ";
 int n;
 cin >> n;
 for(int k=0; k<n; k++){
   string s;
   cin >> s;
   for(int i=0; i<(int)s.size(); i++){
     char c = s[i];
     int count = 0;
     for(i=i+1; i<(int)s.size(); i++){
       if(s[i] != c) break; //先頭と違っていたら
       count++;
    }
    i--; //?
    if(c=='0') continue;
    int num = c-'0'-1; //何故'0'?
    //cout << "#" << num << " " << c << " ";
    int tmp = count % a[num].size();
    cout << a[num][tmp];
    }
    cout << endl;
 }
 return 0;
}