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 <iostream>
#include <string>
using namespace std;

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

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

		string ans = ""; 
		int btn = 0, count = 0;
		for(int j = 0; j < input.size(); j++){
			if(btn == 0 && (int)input[j] > 0){
				btn = input[j] - '0';
				count = 0;
			}else if(btn == (int)input[j] - '0'){
				count++;
			}else if((int)input[j] - '0' == 0 && btn > 0){
				ans += botun[btn][count % botun[btn].size()];
				//cout << botun[btn][count % botun[btn].size()] << " ";
				btn = 0;
				count = 0;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  string str[9];
  str[0] = ".,!? ";
  str[1] = "abc";
  str[2] = "def";
  str[3] = "ghi";
  str[4] = "jkl";
  str[5] = "mno";
  str[6] = "pqrs";
  str[7] = "tuv";
  str[8] = "wxyz";

  string a;
  int h,t = 0;
  cin >> h;
  while (t < h) {
    cin >> a;
    int i = 0;
    do {
      int n = 0,m = 0;
      while (a[i] != '0') {
        m = a[i] - '0';
        n++;
        i++;
      }
      int j;
      if (m == 7 || m == 9) {
        j = n%4 - 1;
        if (j == -1) {
          j = 3;
        }
        cout << str[m-1][j];
      }
      else if (m == 1) {
        j = n%5 - 1;
        if(j == -1){
          j = 4;
        }
        cout << str[m-1][j];
      }
      else if (m == 0) {

      }
      else{
        j = n%3 - 1;
        if (j == -1) {
          j = 2;
        }
        cout << str[m-1][j];
      }
      if (a[i+1]) {
        i++;
      }
    }while(a[i+1]);
    cout << endl;
    t++;
  }
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	vector<string> vvc;
	vvc.push_back(".,!? ");
	vvc.push_back("abc");
	vvc.push_back("def");
	vvc.push_back("ghi");
	vvc.push_back("jkl");
	vvc.push_back("mno");
	vvc.push_back("pqrs");
	vvc.push_back("tuv");
	vvc.push_back("wxyz");
	int n;
	cin >> n;
	while (n--){
		string s;
		string ans = "";
		cin >> s;
		int renzoku=0;
		char current='0';
		REP(i,s.length()){
			if (current!=s[i]){
				if (current != '0'){
					ans += vvc[current - '0' - 1][renzoku%vvc[current - '0' - 1].size()];
				}
				current = s[i];
				renzoku = 0;
			}
			else{
				renzoku++;
			}
		}
		cout << ans << endl;
	}

}

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

typedef pair<char, int> P;
vector<P> v;

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

int main(){
	int n;
	cin >> n;
for(int i=0; i<n; i++){	
	
	string s;
	cin >> s;
	int len = s.size();
	
	int head = 0;
	for(int i=0; i < len; i++){
		if(s[i] == '0') head++;
		else break;
	}
	
	
	int body = -1;
	for(int i=head; i<len; i++){
		body++;
		if(s[i] == '0'){
			if(s[i-1] != '0'){
				v.push_back(P(s[i-1], body));
			}
			body = -1;
		}
	}
	
	for(int i=0; i<(int)v.size(); i++){
		if(N2C(v[i].first, v[i].second) == 'A') continue;
		else cout << N2C(v[i].first, v[i].second);
	}
	cout << endl;
	
	v.clear();
	//debug
	/*
	for(int i=0; i<(int)v.size(); i++){
		cout << v[i].first << " " << v[i].second << endl;
	}
	*/
	
}//end	
	
	return 0;
}