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>

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod[10] = {0,5,3,3,3,3,3,4,3,4};

char moji[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 main(void){
    int N; cin >> N;
    rep(i, N){
        string res = "";
        string S; cin >> S;
        int lenS = S.length();
        int idx = 0;
        while(idx < lenS){
            int row = 0;
            int num = S[idx] - '0';
            while(S[idx++] != '0'){
                row++;
            }
            if(num > 0){
                res += moji[num][(row-1) % mod[num]];
            }
        }
        cout << res << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
	int a[1030];
	int k;
	stringstream sout;
	string b;
	int kari;
	while (cin >> b) {
		kari = 0;
		int rireki[10] = {0};
		k = b.size();
		for (int i = 0; i < k; i++) {
			sout.str("");
			sout.clear();
			sout << b[i];
			sout >> a[i];
		}
		for (int i = 0; i < k-1; i++) {
			if(a[i] != a[i+1] && a[i+1] == 0 && a[i] != 0) {
				kari = 1;
				if (a[i] == 1) {
					if(rireki[1] % 5 == 0) {
						printf(".");
					} else if (rireki[1] % 5 == 1) {
						printf(",");
					} else if (rireki[1] % 5 == 2) {
						printf("!");
					} else if (rireki[1] % 5 == 3) {
						printf("?");
					} else {
						printf(" ");
					}
					rireki[1] = 0;
				} else if (a[i] == 2) {
					//printf(" %d \n", rireki[2]);
					if(rireki[2] % 3 == 0) {
						printf("a");
					} else if (rireki[2] % 3 == 1) {
						printf("b");
					} else {
						printf("c");
					}
					rireki[2] = 0;
				} else if (a[i] == 3) {
					if (rireki[3] % 3 == 0) {
						printf("d");
					} else if (rireki[3] % 3 == 1) {
						printf("e");
					} else {
						printf("f");
					}
					rireki[3] = 0;
				} else if (a[i] == 4) {
					if (rireki[4] % 3 == 0) {
						printf("g");
					} else if (rireki[4] % 3 == 1) {
						printf("h");
					} else {
						printf("i");
					}
					rireki[4] = 0;
				} else if (a[i] == 5) {
					if (rireki[5] % 3 == 0) {
						printf("j");
					} else if (rireki[5] % 3 == 1) {
						printf("k");
					} else {
						printf("l");
					} 
					rireki[5] = 0;
				} else if (a[i] == 6) {
					if (rireki[6] % 3 == 0) {
						printf("m");
					} else if (rireki[6] % 3 == 1) {
						printf("n");
					} else {
						printf("o");
					}
					rireki[6] = 0;
				} else if (a[i] == 7) {
					if (rireki[7] % 4 == 0) {
						printf("p");
					} else if (rireki[7] % 4 == 1) {
						printf("q");
					} else if (rireki[7] % 4 == 2) {
						printf("r");
					} else {
						printf("s");
					}
					rireki[7] = 0;
				} else if (a[i] == 8) {
					if (rireki[8] % 3 == 0) {
						printf("t");
					} else if(rireki[8] % 3 == 1) {
						printf("u");
					} else {
						printf("v");
					}
					rireki[8] = 0;
				} else {
					if (rireki[9] % 4 == 0) {
						printf("w");
					} else if (rireki[9] % 4 == 1) {
						printf("x");
					} else if (rireki[9] % 4 == 2) {
						printf("y");
					} else {
						printf("z");
					}
					rireki[9] = 0;
				}
			} else {
				if (a[i] == 0 || (a[i] != a[i+1])) {
					rireki[a[i]] = 0;
					continue;
				}
				rireki[a[i]]++;
			}
		}
		if (kari == 1) {
			printf("\n");
			}
	}
	return 0;
}

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


#define REP(i,n) for(int i= 0;i < n;i++)
	
char mozi[][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 a[] = {5,3,3,3,3,4,3,4};

int c;
char buf;
string str;
int n;
	
int main()
{
	n = 0;
	cin >> n;
	REP(i,n)
	{
		cin >> str;
		REP(j,str.size())
		{
			buf = str[j];
			if(buf == '0')continue;
			j++;c = 0;
			while(str[j] != '0')
			{
				c++;j++;
			}
			cout << mozi[(buf - '0')-1][c%a[buf - '0'-1]] ;
		}
		
		cout << endl;
		
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int n;

map<char, vector<char>> mp = {
   {'1', {'.', ',', '!', '?', ' '}},
   {'2', {'a', 'b', 'c'}},
   {'3', {'d', 'e', 'f'}},
   {'4', {'g', 'h', 'i'}},
   {'5', {'j', 'k', 'l'}},
   {'6', {'m', 'n', 'o'}},
   {'7', {'p', 'q', 'r', 's'}},
   {'8', {'t', 'u', 'v'}},
   {'9', {'w', 'x', 'y', 'z'}},
};

void solve() {
   debug(mp['1'][0])
   debug(mp['1'][1])
   debug(mp['1'][2])

   exit(0);
}

int main() {
   // solve();
   cin >> n;
   while (n--) {
      string s;
      cin >> s;

      string ans = "";
      int size = s.size();
      for (int i = 0; i < size; i++) {
         if (s[i] == '0') continue;
         int cnt = 0;
         int idx = i;
         repp (j, i, size) {
            if (s[i] != s[j]) break;
            idx = j;
            cnt++;
         }
         int tSize = mp[s[i]].size();
         // printf("mp[%c][%d], %d\n", s[i], cnt%tSize, tSize);
         cnt--;
         if (cnt >= 0) {
            char c = mp[s[i]][cnt % tSize];
            ans += c;
         }
         i = idx;
      }

      cout << ans << endl;
   }

   return 0;
}