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 <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    int n;cin>>n;
    vector<vector<char>> v={{},{'.',',','!','?',' '},{'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'}};
    bool f=false;
    rep(j,0,n){
        string s;
        cin>>s;
        int x,t=-1;
        rep(i,0,s.length()){
            if(!f){
                f=true;
                x=s[i]-'0';
            }
            
            if(s[i]!='0'){
                t++;
                if(x==9||x==7){
                    if(t==4)t=0;
                }else if(x==1){
                    if(t==5)t=0;
                }else{
                    if(t==3)t=0;
                }
            }else {
                if(t!=-1)cout<<v[x][t];
                f=false;
                t=-1;
            }
        }
        cout<<endl;
    }
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

char top[8] = {'a', 'd', 'g', 'j', 'm', 'p', 't', 'w'};
char mark[5] = {'.', ',', '!', '?', ' '};

int main(){
  int n;
  cin >> n;
  REP(i, n){
    string line;
    cin >> line;
    int cnt = 0;
    REP(j, line.size()){
      if(line[j] == '0'){
        if(cnt == 0) continue;
        if(line[j-1] == '1')
          cout << mark[(cnt-1)%5];
        else{
          int kind = line[j-1] == '7' or line[j-1] == '9' ? 4 : 3;
          cout << char(top[line[j-1] - '2'] + (cnt - 1) % kind);
        }
        cnt = 0;
      }
      else cnt++;
    }
  cout << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <queue>

#define MAX 100005
#define ll long long int
using namespace std;

int main(void)
{
	string s; // input
	int n;
	int i, j;

	string an;
	int zero = 0; // zero?????´???

	vector <string> ans;
	queue <char> qu;

	char temp;
	int count = 0;
	char tempm; //mozi???????????????????´?




	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> an;

		for (j = 0; j < an.size(); j++) { //qu?????°?????????
			qu.push(an[j]);

		}



		
		while (qu.empty() == 0) {
			count = 0;
			tempm = 'n'; //?????????


			while (1) {
				temp = qu.front();
				if (temp != '0') {
					tempm = temp;
					count++;
					qu.pop();
				}
				else { //0?????£??????
					qu.pop();
					break;
				}


			}



			if (tempm == '1') { // 1?????¨???
				count = count % 5;

				switch (count) {
				case 1:
					s.push_back('.');
					break;
				case 2:
					s.push_back(',');
					break;
				case 3:
					s.push_back('!');
					break;
				case 4:
					s.push_back('?');
					break;
				case 0:
					s.push_back(' ');
					break;
				}
			}
			else if (tempm == '2') { // 2
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('a');
					break;
				case 2:
					s.push_back('b');
					break;
				case 0:
					s.push_back('c');
					break;

				}
			}
			else if (tempm == '3') { // 3
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('d');
					break;
				case 2:
					s.push_back('e');
					break;
				case 0:
					s.push_back('f');
					break;

				}
			}
			else if (tempm == '4') { // 4
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('g');
					break;
				case 2:
					s.push_back('h');
					break;
				case 0:
					s.push_back('i');
					break;

				}
			}
			else if (tempm == '5') { // 5
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('j');
					break;
				case 2:
					s.push_back('k');
					break;
				case 0:
					s.push_back('l');
					break;

				}
			}
			else if (tempm == '6') { // 6
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('m');
					break;
				case 2:
					s.push_back('n');
					break;
				case 0:
					s.push_back('o');
					break;

				}
			}
			else if (tempm == '7') { // 7
				count = count % 4;
				switch (count) {
				case 1:
					s.push_back('p');
					break;
				case 2:
					s.push_back('q');
					break;
				case 3:
					s.push_back('r');
					break;
				case 0:
					s.push_back('s');
					break;

				}
			}
			else if (tempm == '8') { // 8
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('t');
					break;
				case 2:
					s.push_back('u');
					break;
				case 0:
					s.push_back('v');
					break;

				}
			}
			else if (tempm == '9') { // 9
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('w');
					break;
				case 2:
					s.push_back('x');
					break;
				case 3:
					s.push_back('y');
					break;
				case 0:
					s.push_back('z');

				}
			}




		}

		ans.push_back(s);
		



		s.clear();
	}

	for (i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}


	return (0);
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INT = 1e9;
const ll LINF = 1e18;

string s;
vector<string> button(10);
void init(){
    button[1] = ".,!? ";
    button[2] = "abc";
    button[3] = "def";
    button[4] = "ghi";
    button[5] = "jkl";
    button[6] = "mno";
    button[7] = "pqrs";
    button[8] = "tuv";
    button[9] = "wxyz";
}
string solve(){
    string res;
    replace(s.begin(),s.end(),'0',' ');
    s += "#";
    stringstream ss; ss << s;
    while(true){
        string X; ss >> X;
        if(X == "#") break;
        int i = X[0] - '0';
        int j = (X.length()-1)%(int)button[i].length();
        res += button[i][j];
    }
    return res;
}
int main(void){
    cin.tie(0); ios_base::sync_with_stdio(false);
    init();
    int T; cin >> T;
    while(T--){
        cin >> s;
        cout << solve() << endl;
    }
    return 0;
}