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 <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
	char inputString[80],outputString[80], hoge[2];
	char str;//êIÉê¶ªf[^ðÛ·éÏ
	int length,count,push,index,dataSet;
	int p[9][5] = { //e{^ðµ½Æ«ÌÏÚð ç©¶ßpÓ(óÌvfÍ@É·é)
		{'.' , ',' , '!' , '?' , ' '},
		{'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' , '@'},
	}; 
	scanf("%d", &dataSet);//ßÉf[^ZbgðüÍ

	for(int i=0 ; i<dataSet ; i++){//f[^ZbgÌ¾¯üÍ³¹é
		//ÏÌú»
		count = 0;
		index = 0;
		push  = 0;
		str   = 0;

		scanf("%s", inputString);//0-9Ì¶ÌÀÑüÍ

		length = strlen( inputString );//üÍ¶Ì·³ðßé
		
		for(int i=0 ; i<length ; i++){//ê¶¸Â¶Ì·³ª¾¯²×é

			//¶ðlÉÏ··é(Ï·µ½0-9ª»ÌÜÜ¶ÌîñðÂzñÌY¦ÉÎ)
			hoge[0] = inputString[i];
			push = atoi(hoge);

			if(push==0){//mè{^:0¾Á½ç
				count = 0;
				if(str!=0){
					//êIÉÛ¶µÄ¢½¶ð¦ÉÇÁ
					outputString[index] = str;
					outputString[index+1] = '\0';
					str = 0;
					index++;
				}
			}
			else{//0ÈOÌ{^¾Á½ç

				//êIÉ»ÝÌ¶ðÛ¶
				str = p[push-1][count];
				//{^ðµ½ñðâ·
				count++;
				if(p[push-1][count]=='@' || count==5){
					count = 0;//{^ðµ½ñð0É·é
				}
			}
		}

		//¦Ì¶ñoÍ
		printf("%s \n", outputString );
	}

	return 0;
}

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

int main(void){
    const char character[][] = {{},
    {'.', ',', '!', '?', ' '},
    {'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;
    string s;
    for(int i = 0; i < n; i++){
        cin >> s;
        int index;
        for(index = i; s[index] != '0'; index++);
        int length = index - i;
        cout << character[s[i] - '0'][length / sizeof(character[s[i] - '0'] / character[s[i] - '0'][0])];
        i = index;
    }
    cout << endl;
    return 0;
}

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

char a[5] = {'.', ',', '!', '?', ' '};

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		string str;
		cin >> str;
		int t = 0, s = -1;
		for(int j = 0; j < str.size(); j++){
			if(str[j] == '0'){
				if(t == 0) continue;
				if(t == 1){
					s %= 5;
					cout << a[s];
				} else if(t <= 6){
					char o = 'a';
					s %= 3;
					o += s + 3*(t-2);
					cout << o;
				} else if(t == 7){
					char o = 'a';
					s %= 4;
					o += s+3*(t-2);
					cout << o;
				} else if(t == 8){
					char o = 'a';
					s %= 3;
					o += s+19;
					cout << o;
				} else{
					char o = 'a';
					s %= 4;
					o += s+22;
					cout << o;
				}
				t = 0;
				s = -1;
			} else{
				t = str[j]-'0';
				s++;
			}
		}
		cout << endl;
	}
}

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

int main() {
    vector<string> v;
    v.push_back(".,!? ");
    v.push_back("abc");
    v.push_back("def");
    v.push_back("ghi");
    v.push_back("jkl");
    v.push_back("mno");
    v.push_back("pqrs");
    v.push_back("tuv");
    v.push_back("wxyz");

    int N;
    cin >> N;
    while (N--) {
        string s;
        cin >> s;
        int x = 0, cnt = 0;
        for (char c : s) {
            if (c == '0') {
                x--;
                cnt--;
                if (x != -1) {
                    cout << v[x][cnt % v[x].size()];
                }
                x = 0;
            } else {
                if (x == 0) {
                    x = c - '0';
                    cnt = 1;
                } else {
                    cnt++;
                }
            }
        }
        cout << endl;
    }
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	string a,b;
	while (cin>>a){
		int la=a.size();
		int c=0;
		for(int i=0;i<la;i++){
			if(a[i]=='0'){
				if(b=="1"){
					c=c%5;
					if(c==1) cout<<".";
					if(c==2) cout<<",";
					if(c==3) cout<<"!";
					if(c==4) cout<<"?";
					if(c==0) cout<<" "; 
				}
				if(b=="2"){
					c=c%3;
					if(c==1) cout<<"a";
					if(c==2) cout<<"b";
					if(c==0) cout<<"c";
				}
				if(b=="3"){
					c=c%3;
					if(c==1) cout<<"d";
					if(c==2) cout<<"e";
					if(c==0) cout<<"f";
				}
				if(b=="4"){
					c=c%3;
					if(c==1) cout<<"g";
					if(c==2) cout<<"h";
					if(c==0) cout<<"i";
				}
				if(b=="5"){
					c=c%3;
					if(c==1) cout<<"j";
					if(c==2) cout<<"k";
					if(c==0) cout<<"l";
				}
				if(b=="6"){
					c=c%3;
					if(c==1) cout<<"m";
					if(c==2) cout<<"n";
					if(c==0) cout<<"o";
				}
				if(b=="7"){
					c=c%4;
					if(c==1) cout<<"p";
					if(c==2) cout<<"q";
					if(c==3) cout<<"r";
					if(c==0) cout<<"s";
				}
				if(b=="8"){
					c=c%3;
					if(c==1) cout<<"t";
					if(c==2) cout<<"u";
					if(c==0) cout<<"v";
				}
				if(b=="9"){
					c=c%4;
					if(c==1) cout<<"w";
					if(c==2) cout<<"x";
					if(c==3) cout<<"y";
					if(c==0) cout<<"z";
				}
				c=0;
				b="0";
			}
			else{
				b=a[i];
				c++;
			}
		}
		cout<<endl;
	}
    return 0;
}

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

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