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(){
  int n;
  char c[10][5];
  c[1][0] = '.';c[1][1] = ',';c[1][2] = '!';c[1][3] = '?';c[1][4] = ' ';
  c[2][0] = 'a';c[2][1] = 'b';c[2][2] = 'c';
  c[3][0] = 'd';c[3][1] = 'e';c[3][2] = 'f';
  c[4][0] = 'g';c[4][1] = 'h';c[4][2] = 'i';
  c[5][0] = 'j';c[5][1] = 'k';c[5][2] = 'l';
  c[6][0] = 'm';c[6][1] = 'n';c[6][2] = 'o';
  c[7][0] = 'p';c[7][1] = 'q';c[7][2] = 'r';c[7][3] = 's';
  c[8][0] = 't';c[8][1] = 'u';c[8][2] = 'v';
  c[9][0] = 'w';c[9][1] = 'x';c[9][2] = 'y';c[9][3] = 'z';
  cin >>n;
  while(n--){
    string s;
    cin >>s;
    for(int i=0,a=0,b=0; i<s.size(); i++){
      if(s[i] == '0' && a == 0) continue;
      else if(s[i] == '0' && a!=0){
	if(a == 1) b%=5;
	else if(a == 7 || a == 9) b%=4;
	else b%=3;
	cout <<c[a][b];
	a = 0;
	b = 0;
      }
      else if(s[i] != '0' && a == 0) a = s[i]-'0';
      else if(s[i] != '0' && a!=0) b++;
    }
    cout <<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  string s[9];
  s[0]=".,!?S";
  s[1]="abc";
  s[2]="def";
  s[3]="ghi";
  s[4]="jkl";
  s[5]="mno";
  s[6]="pqrs";
  s[7]="tuv";
  s[8]="wxyz";
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string t;
    cin>>t;
    int c=0;
    for(int j=0;j<t.size();j++){
      if(t[j]=='0'){
	if(j-1>=0)if(t[j-1]!='0'){
	  if(s[t[j-1]-'1'][(j-c-1)%s[t[j-1]-'1'].size()]=='S')cout<<" ";
	  else cout<<s[t[j-1]-'1'][(j-c-1)%s[t[j-1]-'1'].size()];
	}
	c=j+1;
      }
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

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

int main() {
  int n; cin >> n;
  string s;
  for(int i=0;i<n;++i) {
    cin >> s;
    int cnt=0;
    char t;
    for(int j=0;j<s.size();++j){
      if(s[j]=='0' && cnt) {
	cout << moji(t,cnt);
	cnt=0;
      } else if(s[j]!='0') t=s[j],cnt++;
    }
    cout << endl;
  }
  
  return 0;
}

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

int main(){
  string moji[]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  int i,j,n;
  string figure;
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> figure;
    int count=0;
    for(j = 0; j < figure.size(); j++){
      if(figure[j]-'0'==0){
	continue;
      }else if(figure[j]-'0'!=0){
	char suuji=figure[j];
	if(figure[j+1]-'0'==0){
	  cout << moji[suuji-'0'-1][count%(moji[suuji-'0'-1]).size()];
	  count=-1;
	}
	count++;
      }
    }
    cout << endl;
      }
  return 0;
}

C++: // Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  string m[] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    int cnt = 0, btn = S[0];
    for (int j = 1; j < S.length(); j++) {
      if (S[j] == '0') {
        if (btn != '0') {
          cout << m[btn-'0'-1][cnt%m[btn-'0'-1].length()];
        }
        if (j != S.length()-1) {
          btn = S[j+1];
        }
        cnt = -1;
      } else {
        if (btn != S[j]) {
          btn = S[j];
          cnt = -1;
        }
        cnt++;
      }
    }
    cout<<endl;
  }
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> P;
static const int INF=1<<24;

string s[15];

int main(){
	s[1]=".,!? ";
	s[2]="abc";
	s[3]="def";
	s[4]="ghi";
	s[5]="jkl";
	s[6]="mno";
	s[7]="pqrs";
	s[8]="tuv";
	s[9]="wxyz";
	
	string st;
	int n;
	cin>>n;
	rep(k,n){
		cin>>st;
		P res(0,0);
		//cout<<"size "<<st.size()<<endl;
		rep(i,st.size()){
			if(st[i]!='0'){
				res.F++;
				res.S=st[i]-'0';
			}
			else if(res.S!=0){
				int t;
				if(res.S==1) t=5;
				else if(res.S==7||res.S==9) t=4;
				else t=3;
				cout<<s[res.S][(res.F-1)%t];
				res.F=0;res.S=0;
			}
		}
		if(res.S!=0){
			int t;
			if(res.S==1) t=5;
			else if(res.S==7||res.S==9) t=4;
			else t=3;
			cout<<s[res.S][(res.F-1)%t];
		}
		cout<<endl;
	}
	
	
	return 0;
}

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

int changeNumber(char number)
{
	int num = 0;
	for (char i = 48; i < 58; i++) {
		if (number == i) return num;
		num++;
	}
}

int main(void)
{
	string S, message[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	int sizeS, count, k;
	cin >> count;
	for (int i = 0; i < count; i++) {
		cin >> S;
		k = 0;
		while (k < S.size()) {
			int j = 0, ini = changeNumber(S[k]);
			char str = S[k];
			while (S[k] == str && S[k] != '0') {
				bool flag = true;
				for (int i = 0; i < message[ini].size() && S[k] == str; i++) {
					k++;
					j = i;
					flag = false;
				}
				if (flag) k++;
			}
			if (S[k] == '0') cout << message[ini][j]; 
			k++;
		}
		cout << endl;
	}
	
	return 0;
}