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;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void) {
  vector<vector<char>> c;
  c = {{' '},           {'.', ',', '!', '?', ' '},
       {'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 num;
  cin >> num;
  REP(s, num) {
    string n;
    cin >> n;

    int kind = -1, cnt = 0;
    REP(i, n.size()) {
      if (n[i] == '0') {
        if (kind != -1) {
          cnt = (cnt - 1) % c[kind].size();
          cout << c[kind][cnt];
        }
        kind = -1;
        cnt = 0;
      } else {
        kind = n[i] - '0';
        cnt++;
      }
    }
    cout << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
char c[10][10];
int main(void){
    c[1][0]='.';
    c[1][1]=',';
    c[1][2]='!';
    c[1][3]='?';
    c[1][4]=' ';
    char alpha='a';
    for(int i=2;i<=9;i++){
        int index=0;
        if(i==7|| i==9){
            while(index<4){
                c[i][index]=alpha;
                index++;
                alpha++;
            }
        }
        else{
            while(index<3){
                c[i][index]=alpha;
                index++;
                alpha++;
            }
        }
    }
    int n;
    string s;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        int cnt=0;
        char d='0';
        for(int i=0;i<s.length();i++){
            if(s[i]=='0'){
                if(d!='0'){
                    int x=d-'0';
                    if(x==7||x==9){
                        cout<<c[x][(cnt-1)%4];
                        cnt=0;
                        d='0';
                    }
                    else if(x==1){
                        cout<<c[x][(cnt-1)%5];
                        cnt=0;
                        d='0';
                    }
                    else{
                        cout<<c[x][(cnt-1)%3];
                        cnt=0;
                        d='0';
                    }
                }
            }
            else{
                d=s[i];
                cnt++;
            }
        }
        cout<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
int main()
{
	int n, i, j, k, c, d, x;
	char s[1025], t[10][6] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> s;
		for (j = x = 0, d = 0; j < strlen(s); j++, d = c)
		{
			c = s[j] - '0';
			if (c == 0 && d != 0)
				cout << t[d-1][x%strlen(t[d-1])];
			else if (d == c)
				x++;
			else
				x = 0;
		}
		cout << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n;

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

int main() {
    cin >> n;
    while(n--) {
        string s; cin >> s;
        int slen = s.length();
        vector<char> ans;
        int cc = 0;
        int cno = 0;
        for(int i = 0; i < slen; ++i) {
            int ch = s[i] - '0';
            if(ch == 0) {
                if(cc == 0) continue;
                ans.emplace_back(InputEnter(cno, cc-1));
                cc = 0;
            }else {
                cno = ch;
                cc++;
            }
        }
        for(int i = 0; i < (int)ans.size(); ++i) {
            cout << ans[i];
        }
        cout << endl;
    }
}

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

using namespace std;

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

int main()
{
	int n; scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		string S; cin >> S;

		int count_ = 0;

		for (int i = 0; i < S.size(); i++)
		{
			if (S[i] == '0')
			{
				if (count_ != 0)
				{
					cout << R[S[i - 1] - 49][(count_ - 1) % R[S[i - 1] - 49].size()]; count_ = 0;
				}
			}
			else
			{
				count_++;
			}
		}

		cout << endl;
	}

	return 0;
}