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 <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long int lli;

string charset[10][5] = {
	{},
	{".", ",", "!", "?", " "},
	{"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 loop[10] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	vector<string> ansvec;
	for (int n = 0; n < N; n++){
		string s;
		cin >> s;

		int i = 0;
		int push = -1;
		string ans = "";
		while (i < s.length()){
			int num = stoi(s.substr(i, 1));
			if (num != 0){
				int thisnum = num;
				while (num != 0){
					push++;
					i++;
					num = stoi(s.substr(i, 1));
				}
				ans += charset[thisnum][push % loop[thisnum]];
				push = -1;
			}
			i++;
		}
		ansvec.push_back(ans);
	}

	for (auto it = ansvec.begin(); it != ansvec.end(); it++){
		cout << *it << endl;
	}
	return 0;
}

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

#define PI 4*atan(1)
#define INF 1e8

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

vector<string> button = {".,!?",
           "abc",
           "def",
           "ghi",
           "jkl",
           "mno",
           "pqrs",
           "tuv",
           "wxyz"};


int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    int cnt = 0;
    for(int j = 0; j < s.size(); j++){
      if(s[j] == '0'){
        if(cnt != 0){
          char c;
          int num = s[j-1] - '0';
          if(num - 1 == 0 && (cnt-1)%button[num-1].size() == 4)c = ' ';
          else c = button[num - 1][(cnt-1)%button[num-1].size()];
          cout << c;
          cnt = 0;
        }
      }else{
        cnt++;
      }
    }
    cout << endl;
  }
}

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

using namespace std;

const char keibutton[10][5]={{'\0','\0','\0','\0','\0'},
							 {'.',',','!','?',' '}, //1
						     {'a','b','c'},     //2
						     {'d','e','f'},     //3
						     {'g','h','i'},     //4
						     {'j','k','l'},     //5
						     {'m','n','o'},     //6
						     {'p','q','r','s'}, //7
						     {'t','u','v'},     //8
						     {'w','x','y','z'}};//9


int main(){
	int n,cnt,outcnt,inpcnt;
	char str[1025],outputStr[1025];
	
	cin>>n;
	
	for(int z=0;z<n;z++){
		
		fill(str,str+1025,'\0');
		fill(outputStr,outputStr+1025,'\0');
		cnt=-1;
		inpcnt=0;
		outcnt=0;
		
		cin>>str;
		
		while(true){
			if(str[inpcnt]=='\0'){
				break;
			}
			inpcnt++;
		}
		
		for(int i=0;i<inpcnt;i++){
			if(str[i]=='0'){
				if(i>0 && str[i-1]!='0'){
					outputStr[outcnt]=keibutton[str[i-1]-'0'][cnt];
					outcnt++;
				}
				cnt=-1;
			}
			else if(str[i]=='1'){
				if(cnt>=4){
					cnt=0;
				}
				else{
					cnt++;
				}
			}
			else if(str[i]=='7' || str[i]=='9'){
				if(cnt>=3){
					cnt=0;
				}
				else{
					cnt++;
				}
			}
			else{
				if(cnt>=2){
					cnt=0;
				}
				else{
					cnt++;
				}
			}
		}
		cout<<outputStr<<endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int n,q,l,r;
char d[200005],t[200005];
string s;

int main() {
	cout << fixed << setprecision(18);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		for(int j=0;j<s.length();j++){
			if(s[j]=='0'){continue;}
			long long int memo=(s[j]-'0'),cou=0;
			j++;
			while(s[j]!='0'){
				cou++;
				j++;
			}
			if(memo>=2&&memo<=6){
				cout<<(char)('a'+(memo-2)*3+cou%3);
			}else if(memo==7){
				cout<<(char)('p'+cou%4);
			}else if(memo==8){
				cout<<(char)('t'+cou%3);
			}else if(memo==9){
				cout<<(char)('w'+cou%4);
			}else if(memo==1){
				if(cou%5==0){
					cout<<'.';
				}else if(cou%5==1){
					cout<<',';
				}else if(cou%5==2){
					cout<<'!';
				}else if(cou%5==3){
					cout<<'?';
				}else if(cou%5==4){
					cout<<' ';
				}
				
			}
			
		}
		cout<<endl;
	}
}

C++: #include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
using namespace std;

int main(){
	int N;
	cin>>N;
	string keitai[10]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	while(N--){
		string s;
		cin>>s;

		string ans="";
		int b=0,c=0;
		REP(i,0,(int)s.size()){
			if(s[i]=='0'){
				if(b!=0){
					int num=(c+keitai[b].size()-1)%keitai[b].size();
					ans.push_back(keitai[b][num]);
					b=0,c=0;
				}
			}
			else{
				b=s[i]-'0';
				c++;
			}
		}
		p(ans);
	}
	return 0;
}

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

int n;
char s[1030];
char list[9] = {'a', 'd', 'g', 'j', 'm', 'p', 't', 'w'};
char one[5] = {'.', ',', '!', '?', ' '};

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    char count = -1;
    bool flag = false;
    for (int j = 0; s[j] != 0; j++) {
      if (s[j] == '0') {
        if (!flag) continue;
        if (s[j-1] == '1') printf("%c", one[count % 5]);
        else if (s[j-1] == '7' || s[j-1] == '9') printf("%c", list[s[j-1] - '2'] + count % 4);
        else printf("%c", list[s[j-1] - '2'] + count % 3);
        flag = false;
        count = -1;
      } else {
        flag = true;
        count++;
        if (count == 60) count = 0;
      }
    }
    printf("\n");
  }
}

C++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2006

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

string table[10] = { "#", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

int main() 
{
	int N;
	cin >> N;
	rep(nth,N)
	{
		int count=0;
		string msg;
		cin >> msg;
		rep(i,msg.length())
		{
			if(msg[i] == msg[i+1]){
			count++;
			}else{
				string tmp = table[(msg[i]-'0')];
				char word = tmp[ count % (tmp.length()) ];
				if(word != '#'){ cout << word; }
				count=0;
			}
		}
		cout << endl;
	}
	return 0;
}