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>

using namespace std;

typedef long long ll;
typedef pair<int, int> duo;

#define TT template<typename T>
TT T    sq(T x){ return x*x; }
TT int  ubnd(vector<T>& v,T x){ return upper_bound(v.begin(), v.end(), x) - v.begin(); }
TT int  lbnd(vector<T>& v,T x){ return lower_bound(v.begin(), v.end(), x) - v.begin(); }
TT void sort(T& v){ sort(v.begin(), v.end()); }
TT void revs(T& v){ reverse(v.begin(), v.end()); }
TT void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TT void show(T& v,char d=' ',char e='\n'){for(int i=0;i<v.size();++i)cout<<v[i]<<((i==v.size()-1)?e:d);}
TT void inpt(vector<T>& v,int n){ v.reserve(n);for(int i=0;i<n;++i){T x; cin>>x; v.push_back(x);} }
TT T In(){ T x; cin >> x; return x; }

static inline void fast_io(){ ios::sync_with_stdio(0); cin.tie(0); }
static inline int in(){ int x; scanf("%d", &x); return x; }
static inline string instr(){ string x; cin >> x; return x; }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};

vector<string> split(const string& s, char d)
{
  stringstream ss(s);
  vector<string> vs;
  string token;
  while (getline(ss, token, d)) vs.push_back(token);
  return vs;
}

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

  int n;
  cin >> n;
  for (int i = 0; i < n; i++){
    string s;
    cin >> s;
    vector<string> vs = split(s, '0');
    for (int j = 0; j < vs.size(); j++){
      if (!vs[j].size()) continue;
      int tid = vs[j][0] - '1';
      cout << table[tid][(vs[j].size() - 1) % table[tid].size()];
    }
    cout << "\n";
  }
  return (0);
}

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

using namespace std;

char num[8]={'a','d','g','j','m','p','t','w'};
int size[8]={3,3,3,3,3,4,3,4};
int main(void){
	string str;
	int n;
	scanf("%d",&n);
	for(int ddd=0;ddd<n;ddd++){
		int cnt=0;
		string res;
		cin >> str;
		for(int i=0;i<str.size();i++){
			if(i==0){
				if(str[i]!='0')cnt++;
			}else{
				if(str[i]!='0')cnt++;
				if(str[i]=='0'){
					if(str[i-1]=='0')continue;
					if(str[i-1]=='1'){
						cnt=(cnt+4)%5;
						if(cnt==0)res+='.';
						if(cnt==1)res+=',';
						if(cnt==2)res+='!';
						if(cnt==3)res+='?';
						if(cnt==4)res+=' ';
					}else res+=num[str[i-1]-'0'-2]+(cnt-1+size[str[i-1]-'0'-2])%size[str[i-1]-'0'-2];
					cnt=0;
				}
			}
		}

		cout << res << endl;
	}
	return 0;
}

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

using std::cin;
using std::cout;
using std::endl;

char keitai[][6] =
{
	".,!? ",	
	"abc",
	"def",
	"ghi",
	"jkl",
	"mno",
	"pqrs",
	"tuv",
	"wxyz"
	};

char out_keitai(int num, int count) {
	if (num == 1) {
		if (count%5 != 0) {
			return keitai[num-1][(count%5)-1];
		}else {
			return keitai[num-1][4];
		}
	}else if (num == 7 || num == 9) {
		if (count%4 != 0) {
			return keitai[num-1][(count%4)-1];
		}else {
			return keitai[num-1][3];
		}
	}else {
		if (count%3 != 0) {
			return keitai[num-1][(count%3)-1];
		}else {
			return keitai[num-1][2];
		}
	}
}
int main(void) {
	int n;
	char inp;
	std::string str;

	cin >> n;
	cin.ignore(2);

	for (int i = 0; i < n; i++) {
		getline(cin, str);
		int num;
		int count = 0;
		for (int j = 0; j < str.length(); j++) {
			std::string dstr;
			dstr = str.substr(j,1);
			num = atoi(dstr.c_str());
			if (num != 0) {
				count++;
				int seq = 1;
				int next_num;
				while (seq) {
					dstr = str.substr(j+1,1);
					next_num = atoi(dstr.c_str());
					if (num == next_num) {
						count++;
						j++;
					}else {
						seq = 0;
						cout << out_keitai(num,count);
						count = 0;
					}
				}	
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
vector<string> key={".,!? ","abc","def","ghi","jkl","mno",
					"pqrs","tuv","wxyz"};
int main(){
	int n;	cin>>n;
	while(n--){
		string s;	cin>>s;
		s+='0';
		string ret="";
		for(int i=1;i<s.size();i++){
			while(i<s.size()&&s[i]==s[i-1]&&s[i]=='0'){
				s.erase(s.begin()+i);
			}
		}
		while(s[0]=='0')	s.erase(s.begin());
		int type=s[0]-'0'-1;
		int push=0;
		for(int i=1;i<s.size();i++){
			if(type==s[i]-'0'-1)	push=(push+1)%key[type].size();
			else if(s[i]=='0'){
				ret+=key[type][push];
				if(i+1<s.size()){
					type=s[i+1]-'0'-1;
					push=-1;
				}
				else 	type=-1;
			}
			else{
				ret+=key[type][push];
				type=s[i]-'0'-1;
				push=0;
			}
		}
		if(type!=-1){
			ret+=key[type][push];
		}
		cout<<ret<<endl;
	}
	return 0;
}