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;
using LL = long long;

int main(){
    int n;cin >> n;
    vector<vector<char>> bottoms = {{'.', ',', '!', '?', ' '},
                                    {'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'},
                                   };
    for(int i = 0;i < n;i++){
        string s;cin >> s;
        vector<int> indexes(9);
        string ans;
        for(char c : s){
            if(c == '0'){
                for(int a = 0;a < 9;a++){
                    if(indexes.at(a) != 0){
                        ans += bottoms.at(a).at((indexes.at(a)-1)%(bottoms.at(a).size()));
                        indexes = vector<int>(9,0);
                        break;
                    }
                }
                continue;

            }
            int w = c - '1';
            indexes.at(w)++;
        }
        cout<<ans<<endl;
    }
}

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

using namespace std;

int main(){
	char moji[10][6];
	strcpy(moji[1],".,!? ");
	strcpy(moji[2] ,"abc  ");
strcpy(moji[3], "def  ");
strcpy(moji[4],"ghi  ");
strcpy(moji[5],"jkl  ");
strcpy(moji[6],"mno  ");
strcpy(moji[7],"pqrs ");
strcpy(moji[8],"tuv  ");
strcpy(moji[9],"wxyz ");

	string str;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>str;
		int cnt=0;
		int num=0;
		for(int j=0;j<str.size();j++){
			if(str.at(j)=='0')continue;
			cnt=0;
			num=str.at(j)-'0';
			if(j==str.size()-2){
				cout<<moji[num][cnt];
				break;
			}

			while(str.at(j)==str.at(j+1)){
				cnt++;
				j++;
				if(j==str.size()-2){
					break;
				}
			}

			if(num==1){
				cnt%=5;
			}
			else if(num==7||num==9){
				cnt%=4;
			}
			else{
				cnt%=3;
			}

			cout<<moji[num][cnt];
		}
		cout<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
string s,data[9]={
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};
int n,i,p,t;
int main(){
	cin>>n;while(n--){
		cin>>s,t=1,p=s[0]-'0';
		for(i=1;i<s.length();i++){
			if(s[i]=='0'){
				if(p!=0)cout<<data[p-1][(t-1)%data[p-1].length()];
				i++,p=s[i]-'0',t=1;
			}else if(p==0)p=s[i]-'0';
			else t++;
		}
		cout<<endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  vector<string> v = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
  int q; cin >> q;
  while(q > 0) {
    q--;
    string s; cin >> s;
    vector<pair<int, int>> p;
    char now = s[0];
    int cnt = 1;
    for(int i=1;i<(int)(s.size());++i) {
      if(s[i] == now) {
        cnt++;
      } else {
        p.push_back({now-'0', cnt});
        now = s[i];
        cnt = 1;
      }
    }
    p.push_back({now-'0', cnt});
    string ans = "";
    for(int i=0;i<(int)(p.size())-1;++i) {
      if(p[i].first != 0 && p[i+1].first == 0) {
        ans.push_back(v[p[i].first][(p[i].second-1) % (int)(v[p[i].first].size())]);
      }
    }
    cout << ans << endl;
  }
}

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

int main(){
	string str;
	char m[10000],a[10000],p,c[10000];
	char b[10][5]={{'-','-','-','-','-'},{'.',',','!','?',' '},{'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','-'}};
	int n;
	int d=-1;
	int e=0;
	int j;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>str;
		p=0;
		j=0;
		d=-1;
		e=0;
		for(int i=0;i<str.size();i++){
			if(i==0){
				d=0;
				e=str[i]-'0';
			}
			else if(str[i-1]!=str[i]){
				if(str[i-1]!='0'){
					c[j]=b[e][d];
					j++;
				}
				d=0;
				e=str[i]-'0';
			}
			else{
				d++;
				if(b[e][d]=='-' || d==5){
					d=0;
				}
			}
		}
		for(int i=0;i<j;i++){
			cout<<c[i];
		}
		cout<<endl;
	}
	return 0;
}

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

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

    cin >> n;

    while( n-- )
    {
        cin >> str;

        int j = 0;
        char d;
        for( int i = 0; i < str.size(); i++ )
        {
            if( str[i] == '0' )
            {
                if( i - 1 >= 0 && str[i-1] != '0' )
                    cout << d;
                j = 0;
            }
            else if( str[i] == '1' )
            {
                d = c[j];
                j++;
                j %= 5;
            }
            else if( str[i] == '7' || str[i] == '9' )
            {
                d = b[str[i]-'0'-7][j];
                j++;
                j %= 4;
            }
            else
            {
                d = a[str[i]-'0'-2][j];
                j++;
                j %= 3;
            }
        }
        cout << endl;
    }
    return 0;
}

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

string str[10]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		int b=0,c=0;
		for(int j=0;j<s.size();j++){
			if(s[j]=='0'){
				if(b){
					cout<<str[b][c%str[b].size()];
				}
				b=0;
			}else{
				if(s[j]-'0'==b){
					c++;
				}else{
					b=s[j]-'0';
					c=0;
				}
			}
		}
		cout<<endl;
	}
	return 0;
}