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++: // Author :
// Date :
// Problem:
// Solution:
// Comment:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstring>

#define pp push
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

using namespace std;

void play(string str){
    string mas[]={"x",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
    int lng = 0;
    
    for(int i = 0; i < str.size() ; i++){
        if(str[i] == '0'){
            if(lng!=0){
                //cout << (lng-1) << " " << mas[str[i-1]-'0'].size() << endl;
                cout << mas[str[i-1]-'0'][(lng-1)%mas[str[i-1]-'0'].size()];
                lng = 0;
            }
        }
        else lng++;
    }
    cout << endl;
}

main(){
    //freopen("2006-input.txt","r",stdin);
    //freopen("test.txt","w",stdout);
    
    int t;
    string str;
    
    cin >> t;
    
    while(t--){
        cin >> str;
        
        play(str);
    }
    #ifdef GEREL
        for(;;);
    #endif

    return 0;
}

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

char buf[100];
const char *data[10];

int main() {
  data[0] = "";
  data[1] = ".,!? ";
  data[2] = "abc";
  data[3] = "def";
  data[4] = "ghi";
  data[5] = "jkl";
  data[6] = "mno";
  data[7] = "pqrs";
  data[8] = "tuv";
  data[9] = "wxyz";

  int t;
  scanf("%d", &t);
  while (t--) {
    scanf(" %s", buf);
    int n = strlen(buf);
    char c = '\0';
    string res;
    int idx = 0;
    for (int i=0; i<n; i++) {
      if (buf[i] == '0') {
        if (c != '\0') {
          res += c;
          c = '\0';
        }
        idx = 0;
      } else {
        c = data[buf[i]-'0'][idx++];
        if (c == '\0') {
          c = data[buf[i]-'0'][0];
          idx = 1;
        }
      }
    }

    printf("%s\n", res.c_str());
  }
}

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

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

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;


int main(){
	
	int n;
	
	vector<char> v[10];
	
	int a[10] = {0, 0, 3, 3, 3, 3, 3, 4, 3, 4};
	
	v[1].push_back('.');
	v[1].push_back(',');
	v[1].push_back('!');
	v[1].push_back('?');
	v[1].push_back(' ');
	
	int index = 2;
	int count = 0;
	
	for(int i = 0; i < 26; i++){
		v[index].push_back('a' + i);
		count++;
		if(count >= a[index]){
			count = 0;
			index++;
		}
	}
	
	cin >> n;
	
	for(int loop = 0; loop < n; loop++){
		
		string str;
		
		cin >> str;
		
		int ref = 0;
		int count = 0;
		
		for(int i = 0; i < str.size(); i++){
			if(ref == 0 && str[i] != '0'){
				ref = str[i] - '0';
			}else if(str[i] != '0'){
				count++;
			}else if(ref != 0 && str[i] == '0'){
				printf("%c", v[ref][count % v[ref].size()]);
				ref = 0;
				count = 0;
			}
		}
		printf("\n");
		
	}
	return 0;
}

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

using namespace std;

int main(){
    string str;
    int n;
    cin >> n;
    for(int x=0;x<n;x++){
        cin >> str;
        int times = 0;
        char kind = 0;
        string ret = "";
        str += '0';
        for(int i=0;i<str.size();i++){
            if(str[i] == '0'){
                if(times != 0){
                    times--;
                    if(kind == '1'){
                        times %= 5;
                        if(times == 0){
                            ret += '.';
                        }else if(times == 1){
                            ret += ',';
                        }else if(times == 2){
                            ret += '!';
                        }else if(times == 3){
                            ret += '?';
                        }else{
                            ret += ' ';
                        }
                    }else if(kind == '2'){
                        ret += 'a' + (times%3);
                    }else if(kind == '3'){
                        ret += 'd' + (times%3);
                    }else if(kind == '4'){
                        ret += 'g' + (times%3);
                    }else if(kind == '5'){
                        ret += 'j' + (times%3);
                    }else if(kind == '6'){
                        ret += 'm' + (times%3);
                    }else if(kind == '7'){
                        ret += 'p' + (times%4);
                    }else if(kind == '8'){
                        ret += 't' + (times%3);
                    }else if(kind == '9'){
                        ret += 'w' + (times%4);
                    }
                }
                times = 0;
            }else{
                times++;
                kind = str[i];
            }
        }
        cout << ret << endl;
    }
}

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

using namespace std;

int main(){
  int n;
  cin>>n;
  cin.ignore();
  while(n--){
    string s;
    getline(cin,s);
    for(int i=0;i<s.size();i++){
      int cn=0;
      char c=s[i];
      for(;s[i]!='0';i++,cn++) ;
      if(c!='0'){
	string bc[]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	cout<<bc[c-'0'][(cn-1)%bc[c-'0'].size()];
      }
    }
    cout<<endl;
  }
  return 0;
}