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;

void bo(int,int);

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

C++: #include <iostream>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)

using namespace std;

int main()
{
  char keitai[10][6] = {{'*', '*', '*', '*', '*', '*'},
                        {'.', ',', '!', '?', ' ', '*'},
                        {'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', '*', '*'},
  };
  string s;
  int x , c;
  char p;
  int n;
  cin >> n;
  cin.ignore();
  REP(k, n){
    getline(cin, s);
    x = c = 0;
    p = '\0';
    REP(i, s.size()){
      int j;
      j = s[i] - '0';
      if(j){
        if(x == j){
          if(keitai[j][c + 1] == '*'){
            c = 0;
            p = keitai[j][c];
          }else{
            c++;
            p = keitai[j][c];
          }
        }else{
          c = 0;
          p = keitai[j][c];
        }
      }else{
        if(p != '\0')
          cout << p;
        p = '\0';
      }
      x = j;
    }
    cout << endl;
  }
}

C++: #include <cstdio>
int main(){
  int N,p,g,a[9]={};
  int i,o;
  char v,prev;
  scanf("%d",&N);
  for(i=1;i<=N+1;i++){
    p=0;
    while(1){
      p++;
      scanf("%c",&v);
      if(v=='\n') break;
      if(v=='1') a[0]++;
      if(v=='2') a[1]++;
      if(v=='3') a[2]++;
      if(v=='4') a[3]++;
      if(v=='5') a[4]++;
      if(v=='6') a[5]++;
      if(v=='7') a[6]++;
      if(v=='8') a[7]++;
      if(v=='9') a[8]++;
      if(v=='0') {
	if(prev=='1') {
	  if(a[0]%5==4) printf("?");
	  if(a[0]%5==1) printf(".");
	  if(a[0]%5==2) printf(",");
	  if(a[0]%5==3) printf("!");
	  if(a[0]%5==0) printf(" ");
	}
	if(prev=='2'){
	  g=a[1]%3;
	  if(g==0) g=3;
	  printf("%c",96+g);
	}
	if(prev=='3'){
	  g=a[2]%3;
	  if(g==0) g=3;
	  printf("%c",99+g);
	}
	if(prev=='4'){
	  g=a[3]%3;
	  if(g==0) g=3;
	  printf("%c",102+g);
	}
	if(prev=='5'){
	  g=a[4]%3;
	  if(g==0) g=3;
	  printf("%c",105+g);
	}
	if(prev=='6'){
	  g=a[5]%3;
	  if(g==0) g=3;
	  printf("%c",108+g);
	}
	if(prev=='7'){
	  g=a[6]%4;
	  if(g==0) g=4;
	  printf("%c",111+g);
	}
	if(prev=='8'){
	  g=a[7]%3;
	  if(g==0) g=3;
	  printf("%c",115+g);
	}
	if(prev=='9'){
	  g=a[8]%4;
	  if(g==0) g=4;
	  printf("%c",118+g);
	}
	for(o=0;o<=8;o++){
	  a[o]=0;
	}
      } 
      prev=v;
    }
    if(i>=2)   printf("\n");
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	vector<string> v(9);
	v[0] = ".,!? ";
	v[1] = "abc";
	v[2] = "def";
	v[3] = "ghi";
	v[4] = "jkl";
	v[5] = "mno";
	v[6] = "pqrs";
	v[7] = "tuv";
	v[8] = "wxyz";
	int T; cin >> T;
	while (T--) {
		string s; cin >> s;
		int _i = -1, _j = -1;
		for (int k = 0; k < s.length(); k++) {
			int i = s[k] - '0';
			if (i == 0) {
				if (_i != -1) {
					cout << v[_i][_j];
					_i = -1; _j = -1;
				}
			}
			else {
				_i = i - 1;
				_j = (_j + 1) % v[_i].length();
			}
		}
		cout << endl;
	}
}

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

char s[10][10] = {
  {},
  {'.', ',', '!', '?', ' '},
  {'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 main()
{
  int set;
  cin >> set;
  for(int cn = 0; cn < set; cn++)
  {
    string a;
    cin >> a;
    int n = 0;
    char c = '0';
    for(int i = 0; i < a.length(); i++)
    {
      if(a[i] != '0')
      {
        c = a[i];
        n++;
      }
      else
      {
        if(c != '0')
        {
          n--;
          int cc = c - '0';
          switch(cc)
          {
            case 0: break;
            case 1: cout << s[cc][n % 5]; break;
            case 2: case 3: case 4: case 5: case 6: case 8: cout << s[cc][n % 3]; break;
            case 7: case 9: cout << s[cc][n % 4]; break;
          }
        }
        n = 0;
        c = '0';
      }
    }
    cout << endl;
  }
}