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<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

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

int main() {
	int n=in();
	while(n--){
		string str;
		cin>>str;
		int i;
		int a=0,b=0;
		for(i=0;i<str.size();i++){
			if(str[i]=='0'){
				if(b!=0)cout<<ch[a][(b-1)%ch[a].size()];
				b=0;
			}else{
				a=str[i]-'1';
				b++;
			}
		}
		cout<<endl;
	}
	return 0;
}

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


int main(){
	char list[][6]={
	{"     "},
	{".,!? "},
	{"abc  "},
	{"def  "},
	{"ghi  "},
	{"jkl  "},
	{"mno  "},
	{"pqrs "},
	{"tuv  "},
	{"wxyz "} };
	int m[10] = {1,5,3,3,3,3,3,4,3,4};
	int count,n,i,buf;
	string str;
	cin >> n;
	while(n--){
		cin >> str;
		count=0;
		for(i=0;i<str.size() && str[i]=='0';i++);
		for(;i<str.size();i++){
			if(str[i]!='0'){
				count++;
			}else{
				if(str[i-1]!='0'){
				buf = (int)str[i-1] - (int)'0';
				cout << list[buf][(count-1) % m[buf]];
				count=0;
				}else{
					count=0;
				}
			}
		}
		cout << endl;
        }
        return 0;
}

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

int main(){
  vector<string> moji(10);
  moji[1] = ".,!? ";
  moji[2] = "abc";
  moji[3] = "def";
  moji[4] = "ghi";
  moji[5] = "jkl";
  moji[6] = "mno";
  moji[7] = "pqrs";
  moji[8] = "tuv";
  moji[9] = "wxyz";
  int n =0;cin >> n;

  for(int i = 0;i < n;i++){
    string tmp;
    cin >> tmp;
    string mes = "";
    char keep;
    int flag = 0;
    for(int i = 0;i < tmp.size();i++){
      if(tmp[i] != '0'){
	flag++;
	keep = tmp[i]; 
      }else{
	if(flag > 0){
	  mes += moji[keep-'0'][(flag-1)%(moji[keep-'0'].size())];
	}
	flag = 0;
      }
    }
    cout << mes << endl;
    
    
    
  }
  return 0;
}
int string_to_int(string a){
  stringstream ss;
  ss << a;
  int num;
  ss >> num;
  return num;
}

C++: #include<string>
#include<stdio.h>
using namespace std;

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

int main(){
	int cases;
	cin>>cases;
	while(cases--){
		string str;
		cin>>str;
		
		int mem = 0;//times * 10 + type
		for(int i = 0; i < str.size(); i++){
			int t = (int)(str[i]-'0');
			if(!t){
				if(mem){
					cout<<ctable[mem%10-1].at((mem/10)%ctable[mem%10-1].size());
				}
				mem = 0;
			}else{
				if(mem%10 == t)mem+=10;
				else mem = t;
			}
		}
		cout<<endl;
	}
	return 0;
}

C++: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1e18;

vector<char> c[15];

signed main(){
    c[1].push_back('.');
    c[1].push_back(',');
    c[1].push_back('!');
    c[1].push_back('?');
    c[1].push_back(' ');
    for(int i=2;i<=6;i++){
        for(int j=0;j<3;j++) c[i].push_back((i-2)*3+j+'a');
    }
    for(int i=0;i<4;i++) c[7].push_back(15+i+'a');
    for(int i=0;i<3;i++) c[8].push_back(19+i+'a');
    for(int i=0;i<4;i++) c[9].push_back(22+i+'a');
    int q;
    cin>>q;
    while(q--){
        string s,t;
        cin>>s;
        int m=s.size();
        int l=0;
        int cnt=0;
        while(true){
            char cc=s[l];
            int u=cc-'0';
            if(s[l]!='0'){
                while(s[l]!='0'){
                    l++;
                    cnt++;
                }
                cnt--;
                if(u==7||u==9){
                    cnt%=4;
                }else if(u==1)cnt%=5;
                else cnt%=3;
                t+=c[u][cnt];
                cnt=0;
            }else{
                l++;
            }
            if(l==m) break;
        }
        cout<<t<<endl;
    }
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<char, vector<char>> input;
	input['1'] = {'.', ',', '!', '?', ' '};
	input['2'] = {'a', 'b', 'c'};
	input['3'] = {'d', 'e', 'f'};
	input['4'] = {'g', 'h', 'i'};
	input['5'] = {'j', 'k', 'l'};
	input['6'] = {'m', 'n', 'o'};
	input['7'] = {'p', 'q', 'r', 's'};
	input['8'] = {'t', 'u', 'v'};
	input['9'] = {'w', 'x', 'y', 'z'};
	rep (i, n) {
		string s;
		cin >> s;
		string ans;
		int cnt = 0;
		string temp;
		for (char c : s) {
			if (c != '0') temp += c;
		}
		s = temp;
		char c = s[0];
		REP (i, 1, s.size()) {
			if (s[i] != c) {
				ans += input[c][cnt];
				c = s[i];
				cnt = 0;
			} else {
				cnt = (cnt + 1) % input[c].size();
			}
		}
		ans += input[c][cnt];
		cout << ans << endl;
	}
	return 0;
}