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 <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
#define d_arr(arr, h, w) rep(i,(h) ){ cout << "["; rep(j,(w) ) { cout << (arr)[i][j] << ", "; } cout << "]" << endl;}

typedef pair<int ,int> P;

/*
1: . , ! ? (スペース)
2: a b c
3: d e f
4: g h i
5: j k l
6: m n o
7: p q r s
8: t u v
9: w x y z
0: 確定ボタン
 */

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


int main()
{
    int n;
    int index;
    int count=0;
    string s;
    int loop;
    cin >> loop;
    rep(i, loop)
    {
        string s;
        cin >> s;
        cout << s << endl;
        rep(j, s.size() )
        {
            string st;
            st[0] = s[j];
            n = atoi( &st[0] );
            //cout << n << endl;
            if( n == 0 && count == 0) { continue; }
            else if( n == 0 ) 
            { 
                cout << a[index - 1][(count - 1) % a[index - 1].size() ];  
                count = 0;
            }
            else
            {
                index = n;
                count++;
            }
        }
    }
    //if ( count > 0 ) { cout << a[index - 1][(count - 1) % 9]; count = 0; }
}

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

int main()
{
  string data[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
  int n;
  cin >> n;

  while( n-- ) {
    string s;
    cin >> s;

    int now_p = -1;
    char now_c = '0';
    for(int i=0; i<s.size(); i++) {
      if( s[i] == '0' ) {
	if( now_c == '0' ) continue;
	else {
	  cout << data[now_c-'0'][now_p];
	  now_c = '0';
	  now_p = -1;
	}
      } 
      else {
	now_c = s[i];
	now_p++;
	if( now_p >= data[now_c-'0'].size() ) {
	  now_p = 0;
	}
      }
    }

    cout << endl;
  }
}

C++: #include<iostream>
#include<string>
using namespace std;
string search(int n[]) {
	if (n[0]) {
		if (n[0] == 1) {
			n[0] = 0;
			return ".";
		}
		else if (n[0] == 2) {
			n[0] = 0;
			return ",";
		}
		else if (n[0] == 3) {
			n[0] = 0;
			return "!";
		}
		else {
			n[0] = 0;
			return "?";
		}
	}
	else if (n[1]) {
		if (n[1] % 3 == 1) {
			n[1] = 0;
			return "a";
		}
		else if (n[1] % 3 == 2) {
			n[1] = 0;
			return "b";
		}
		else {
			n[1] = 0;
			return "c";
		}
	}
	else if (n[2]) {
		if (n[2] % 3 == 1) {
			n[2] = 0;
			return "d";
		}
		else if (n[2] % 3 == 2) {
			n[2] = 0;
			return "e";
		}
		else {
			n[2] = 0;
			return "f";
		}
	}
	else if (n[3]) {
		if (n[3] % 3 == 1) {
			n[3] = 0;
			return "g";
		}
		else if (n[3] % 3 == 2) {
			n[3] = 0;
			return "h";
		}
		else {
			n[3] = 0;
			return "i";
		}
	}
	else if (n[4]) {
		if (n[4] % 3 == 1) {
			n[4] = 0;
			return "j";
		}
		else if (n[4] % 3 == 2) {
			n[4] = 0;
			return "k";
		}
		else {
			n[4] = 0;
			return "l";
		}
	}
	else if (n[5]) {
		if (n[5] % 3 == 1) {
			n[5] = 0;
			return "m";
		}
		else if (n[5] % 3 == 2) {
			n[5] = 0;
			return "n";
		}
		else {
			n[5] = 0;
			return "o";
		}
	}
	else if (n[6]) {
		if (n[6] % 4 == 1) {
			n[6] = 0;
			return "p";
		}
		else if (n[6] % 4 == 2) {
			n[6] = 0;
			return "q";
		}
		else if (n[6] % 4 == 3) {
			n[6] = 0;
			return "r";
		}
		else {
			n[6] = 0;
			return "s";
		}
	}
	else if (n[7]) {
		if (n[7] % 3 == 1) {
			n[7] = 0;
			return "t";
		}
		else if (n[7] % 3 == 2) {
			n[7] = 0;
			return "u";
		}
		else {
			n[7] = 0;
			return "v";
		}
	}
	else if (n[8]) {
		if (n[8] % 4 == 1) {
			n[8] = 0;
			return "w";
		}
		else if (n[8] % 4 == 2) {
			n[8] = 0;
			return "x";
		}
		else if (n[8] % 4 == 3) {
			n[8] = 0;
			return "y";
		}
		else {
			n[8] = 0;
			return "z";
		}
	}
	return "";
}


int main() {
	int i;
	cin >> i;
	string num;
	string s;
	int n[9] = {};
	for (int j = 0; j<i; j++) {
		cin >> num;
		for (int j = 0; j < num.size() ; j++) {
			switch (num[j]) {
			case '1':
				if (n[0] == 0)s += search(n);
				n[0]++;
				break;
			case '2':
				if (n[1] == 0)s += search(n);
				n[1]++;
				break;
			case '3':
				if (n[2] == 0)s += search(n);
				n[2]++;
				break;
			case '4':
				if (n[3] == 0)s += search(n);
				n[3]++;
				break;
			case '5':
				if (n[4] == 0)s += search(n);
				n[4]++;
				break;
			case '6':
				if (n[5] == 0)s += search(n);
				n[5]++;
				break;
			case '7':
				if (n[6] == 0)s += search(n);
				n[6]++;
				break;
			case '8':
				if (n[7] == 0)s += search(n);
				n[7]++;
				break;
			case '9':
				if (n[8] == 0)s += search(n);
				n[8]++;
				break;
			default:
				if (n[0]) {
					s += search(n);
				}
				else if (n[1]) {
					s += search(n);
				}
				else if (n[2]) {
					s += search(n);
				}
				else if (n[3]) {
					s += search(n);
				}
				else if (n[4]) {
					s += search(n);
				}
				else if (n[5]) {
					s += search(n);
				}
				else if (n[6]) {
					s += search(n);
				}
				else if (n[7]) {
					s += search(n);
				}
				else if (n[8]) {
					s += search(n);
				}
			}
		}
		cout << s << endl;
		s = "";
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<string>
#include<stdlib.h>

using namespace std;

#define ll long long int
#define ld long double
#define reps(i,f,n) for(int i=f;i<n;i++)
#define rep(i,n) reps(i,0,n)
#define m1 cout<<"move1"<<endl
#define m2 cout<<"move2"<<endl
#define m3 cout<<"move3"<<endl
#define m4 cout<<"move4"<<endl


int main(){
  ll num = 0;
  string s;
  char data[10][7] = {".,!? $","abc$$","def$$","ghi$$","jkl$$","mno$$","pqrs$","tuv$","wxyz$"};
  char ans;
  ll temp = 0;
  ll cou = 0;

  cin>>num;
  // m1;

  rep(i,num){
    cin>>s;
    //m2;
    
    rep(i,s.size()){
      ans = '#';
      cou = 0;
      while(s[i] != '0'){
	//m3;
	temp = s[i] - '0' -1;
	//m3;
	//cout<<temp<<endl;
	ans = data[temp][cou];
	//cout<<temp<<endl;
	//	m4;
	if(data[temp][cou] == '$'){
	  cou = 0;
	  ans = data[temp][cou];
	}
	cou++;
	i++;
      }
      if(ans != '#'){
	cout<<ans;
      }
      
    }
    cout<<endl;
  }
  return 0;
}