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 <algorithm>
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1

using namespace std;

int main() {
  int n, pre, cur, count;
  string s;
  string org[] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
  vector<string> button(org, end(org));
  cin >> n;
  while (n--) {
    cin >> s;
    pre = 0;
    for (int i = 0; i < s.length(); i++) {
      cur = (int)(s[i]-'0');
      if (pre == 0) {
        if (cur != 0) {
          pre = cur;
        }
      } else {
        if (cur == 0) {
          cout << button[pre-1][count];
          pre = 0;
          count = 0;
        } else {
          count = (count+1)%button[pre-1].length();
        }
      }
    }
    cout << el;
  }
}

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

int main(){

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

	char in;
	int col=-1, row=0;
	int num;
	int state = 0;
	while(scanf("%c",&in) != EOF){

		if(in == '0'){
			if(col == -1) col++;
			if(row >= 2 && row <= 6 || row == 8) num = 3;
			else if(row == 1) num = 5;
			else num = 4;

			if(data[row][col%num] != 'E'){
				cout << data[row][col%num];
				state = 1;
			}
			col = -1;
			row = 0;
		}else{
			col++;
			row=in-48;
		}
		if(in == '\n'){
			if(state == 1) cout << endl;
			state = 0;
			col = -1;
			row = 0;
		}

	}
	if(state == 1) cout << endl;
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)

typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
	string ms[] = { "",
					".,!? ",
                    "abc",
					"def",
					"ghi",
					"jkl",
					"mno",
					"pqrs",
					"tuv",
					"wxyz" };

	int n;
	cin >> n;
	rep(TTT, n) {
		string str;
		cin >> str;
		vector<pii> ks;
		int prev = 0;
		int cnt = 0;
		rep(k, str.size()) {
			int i = str[k]-'0';
			if (prev != i) {
				if (prev != 0)
					putchar(ms[prev][cnt]);
				prev = i;
				cnt = 0;
			} else {
				if (prev != 0)
					cnt = (cnt+1)%ms[prev].size();
			}
		}
		if (prev != 0)
			putchar(ms[prev][cnt]);
		putchar('\n');
	}
	return 0;
}

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

C++: #include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf=2147483647;
const long long int My_LInf=9223372036854775807;

vector<string>sts(10);

int main() {
	sts[1] = ".,!? ";
	sts[2] = "abc";
	sts[3] = "def";
	sts[4] = "ghi";
	sts[5] = "jkl";
	sts[6] = "mno";
	sts[7] = "pqrs";
	sts[8] = "tuv";
	sts[9] = "wxyz";
	int n; cin >> n;
	while (n--) {
		string st; cin >> st;
		int select = 0;
		int now = -1;
		for (int i = 0; i < st.size(); ++i) {
			if (st[i] == '0') {
				if (select) {
					cout << sts[select][now];
				}
				select = 0;
				now = -1;
			}
			else {
				select = (st[i]-'0');
				now++;
				now %= sts[select].size();
				
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#define R return

using namespace std;

char convert (int cnt, int num)
{
    int d;
    switch (num)
    {
    case 1:
        d=cnt%5;
        if (d==1) R '.';
        if (d==2) R ',';
        if (d==3) R '!';
        if (d==4) R '?';
        if (d==0) R ' ';
    case 2:
        d=cnt%3;
        if (d==1) R 'a';
        if (d==2) R 'b';
        if (d==0) R 'c';
    case 3:
        d=cnt%3;
        if (d==1) R 'd';
        if (d==2) R 'e';
        if (d==0) R 'f';
    case 4:
        d=cnt%3;
        if (d==1) R 'g';
        if (d==2) R 'h';
        if (d==0) R 'i';
    case 5:
        d=cnt%3;
        if (d==1) R 'j';
        if (d==2) R 'k';
        if (d==0) R 'l';
    case 6:
        d=cnt%3;
        if (d==1) R 'm';
        if (d==2) R 'n';
        if (d==0) R 'o';
    case 7:
        d=cnt%4;
        if (d==1) R 'p';
        if (d==2) R 'q';
        if (d==3) R 'r';
        if (d==0) R 's';
    case 8:
        d=cnt%3;
        if (d==1) R 't';
        if (d==2) R 'u';
        if (d==0) R 'v';
    case 9:
        d=cnt%4;
        if (d==1) R 'w';
        if (d==2) R 'x';
        if (d==3) R 'y';
        if (d==0) R 'z';
    }
}

int main()
{
    int n, c, p;
    string s, ans[200]={};
    cin>>n;
    for (int i=0; i<n; i++)
    {
        c=0; p=0;
        cin>>s;
        for (int j=0; j<s.size(); j++)
        {
            if (s[j]=='0' && p!=0) { ans[i]+=convert(c, p); c=0; p=0; }
            if (s[j]=='0' && p==0) { c=0; }
            else if (s[j]==p) { c++; }
            else { p=s[j]-48; c++; }
        }
    }
    for (int i=0; i<n; i++) cout<<ans[i]<<'\n';
    R 0;
}