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;
#define rep(i,j) for(int i = 0; i < (j); i++)
int main(){int n;cin >> n;string c[] = {"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};	while(n--){string str;cin >> str;string ans = "";rep(i,str.size()){if(str[i] == '0')continue;int sub = i;while(str[i] == str[++sub]);ans += c[str[sub-1]-48][(sub-i-1)%c[str[sub-1]-48].size()];i = sub;}cout << ans << endl;}return 0;}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>
#include <string>

using namespace std;

int main() {

  int t;
  cin >> t;
  array<array<char, 5>, 10> table{ { {}, { '.', ',', '!', '?', ' ' }, { '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' } } };
  array<int, 10> sizes = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4};
  
  for (int i = 0; i < t; i++){
    string line;
    cin >> line;
    int counter = -1;
    int type = -1;
    for(const char& ch : line){
      if(ch == '0'){
	if (type >= 0) {
	  cout << table[type][counter % sizes[type]];
	  type = -1;
	  counter = -1;
	}
      } else {
	type = ch - '0';
	counter++;
      }
    }
    cout << endl;
  } 
}

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

char const mozi1[]={'.',',','!','?',' '},mozi2[]={'a','b','c'},mozi3[]={'d','e','f'},mozi4[]={'g','h','i'},mozi5[]={'j','k','l'},mozi6[]={'m','n','o'},mozi7[]={'p','q','r','s'},mozi8[]={'t','u','v'},mozi9[]={'w','x','y','z'};
void henkan(char *);
char mozi(int,char);
int main(){
	int n;
	cin>>n;

	for(int i=0;i<n;i++){
		char * keitai=new char[1024];
		scanf("%s",keitai);
		henkan(keitai);
		delete[]keitai;
	}
	return 0;
}

void henkan(char * keitai){
	char *hyouzi=new char[72];
	fill(hyouzi,hyouzi+72,0);
	int length=strlen(keitai);
	int cnt=0;
	
	for(int i=0;i<length;i++){
		if(keitai[i]=='0')	continue;
		else{
			int kazu=1;
			while(keitai[i+1]!='0'){
				kazu++;
				i++;
			}
			hyouzi[cnt]=mozi(kazu,keitai[i]);
			i++;
			cnt++;
		}
	}
	
	cout<<hyouzi<<endl;
	delete[] hyouzi;
        return;
}
char mozi(int kazu,char keitai){
	switch (keitai)
	{
	case '1':
		kazu=kazu%5-1;
		if(kazu==-1)	return mozi1[4];
		return mozi1[kazu];
		
	case '2':
		kazu=kazu%3-1;
		if(kazu==-1)	return mozi2[2];
		return mozi2[kazu];
		
	case '3':
		kazu=kazu%3-1;
		if(kazu==-1)	return mozi3[2];
		return mozi3[kazu];
		
	case '4':
		kazu=kazu%3-1;
		if(kazu==-1)	return mozi4[2];
		return mozi4[kazu];
		
	case '5':
		kazu=kazu%3-1;
		if(kazu==-1)	return mozi5[2];
		return mozi5[kazu];
		
	case '6':
		kazu=kazu%3-1;
		if(kazu==-1)	return mozi6[2];
		return mozi6[kazu];
		
	case '7':
		kazu=kazu%4-1;
		if(kazu==-1)	return mozi7[3];
		return mozi7[kazu];
		
	case '8':
		kazu=kazu%3-1;
		if(kazu==-1)	return mozi8[2];
		return mozi8[kazu];
		
	case '9':
		kazu=kazu%4-1;
		if(kazu==-1)	return mozi9[3];
		return mozi9[kazu];
	default:
		return NULL;
	}
}

C++: #include<bits/stdc++.h>
#define REP(s,g) for(s=0;s<g;s++)
using namespace std;


int main(){
  long long i,j,k,l,m,n,o,p,N=100000000000000000;
  long long a,b,c,d,e,f,g,h;
  long long q,r,s,t,u,v,w,x,y,z;
    REP(i,N)
    REP(j,N)
    REP(k,N)
    REP(l,N)
    REP(m,N)
    REP(n,N)
    REP(o,N)
    REP(p,N)
    REP(a,N)
    REP(b,N)
    REP(c,N)
    REP(d,N)
    REP(e,N)
    REP(f,N)
    REP(g,N)
    REP(h,N)
    REP(q,N)
    REP(r,N)
    REP(s,N)
    REP(t,N)
    REP(u,N)
    REP(v,N)
    REP(w,N)
    REP(x,N)
    REP(y,N)
    REP(z,N);
  cout<<"Hello World"<<endl;
  return 0;
}

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

int main(){
  char buf[1030];
  int n,bi,ki;
  int kcount=0,kcode=0;
  char kdata[10][10]={{0,5,3,3,3,3,3,4,3,4},".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  cin >> n;

  for (int i=0;i<n;i++){
    cin >> buf;
    bi=-1;
    kcode=0;
    kcount=0;
    while (buf[++bi]!='\0'){
      if (buf[bi]=='0'&&kcode>0){
        ki=(kcount-1)%kdata[0][kcode];
	cout << kdata[kcode][ki];
	kcode=0;
	kcount=0;
      }
      if (buf[bi]>='1'&&buf[bi]<='9'){
	kcode=buf[bi]-'0';
	kcount++;
      }
    }
    cout << endl;
  }
  return 0;
}

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 % 5 == 1) return '.';
		else if(cnt % 5 == 2) return ',';
		else if(cnt % 5 == 3) return '!';
		else if(cnt % 5 == 4) return '?';
		else if(cnt % 5 == 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;
}