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 <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

string A = ".,!?_",B="abc",C="def",D="ghi",E="jkl",F="mno",G="pqrs",H="tuv",I="wxyz";


int main(){
    int n;
    cin >> n;
    rep(w,n){
        string S;
        cin >> S;
        string ans="";
        int i=0;
        while (i<S.length()) {
            char ch = S[i];
            if(ch=='0'){
                i++;
                continue;
            }
            int t=0;
            while (S[i]!='0' and i<S.length()){
                i++;
                t++;
            }
            if(ch=='1'){
                        int flag = (t-1)%5;
                        if(flag == 4){
                            ans += " ";
                        }else{
                            ans += A[flag];
                        }
                    }
            if(ch=='2'){
                int flag = (t-1)%3;
                ans += B[flag];
            }
            if(ch=='3'){
                int flag = (t-1)%3;
                ans += C[flag];
            }
            if(ch=='4'){
                int flag = (t-1)%3;
                ans += D[flag];
            }
            if(ch=='5'){
                int flag = (t-1)%3;
                ans += E[flag];
            }
            if(ch=='6'){
                int flag = (t-1)%3;
                ans += F[flag];
            }
            if(ch=='7'){
                int flag = (t-1)%4;
                ans += G[flag];
            }
            if(ch=='8'){
                int flag = (t-1)%3;
                ans += H[flag];
            }
            if(ch=='9'){
                int flag = (t-1)%4;
                ans += I[flag];
            }
            i++;
        }
        cout << ans << endl;
    }
}

C++: # 2006.cc

#include <iostream>
#include <string>

using namespace std;

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

int main() {
?? int nnn;
?? cin >> nnn;
?? for (int iii = 0; iii < nnn; ++iii) {
?? ?? string input;
?? ?? cin >> input;
?? ?? int prev = 0, cnt = 0;
?? ?? for (char c : input) {
?? ?? ?? int d = c-'0';
?? ?? ?? if (d == 0) {
?? ?? ?? ?? if (prev != 0) {
?? ?? ?? ?? ??cout << chars[prev][(cnt-1) % chars[prev].size()];
?? ?? ?? ?? }
?? ?? ?? ?? cnt = 0;
?? ?? ?? } else {
?? ?? ?? ?? ++cnt;
?? ?? ?? }
?? ?? ?? prev = d;
?? ?? }
?? ?? cout << endl;
?? }
}

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

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

int main(){
  cin >> N;
  
  for(int i=0; i<N; ++i){
    char input[1025];
    cin >> input;
    char old = '0';
    int count = 0;
    for(int j=0; input[j] != '\0'; ++j){
      if(input[j] == '0'){
        if(old != '0'){
          if('2' <= old && old <= '6'){
            putchar(phone[old-'1'][(count-1)%3]);
          }
          else if(old == '1'){
            putchar(phone[old-'1'][(count-1)%5]);
          }
          else{
            putchar(phone[old-'1'][(count-1)%4]);
          }
        }
        old = input[j];
        count = 0;
      }else{
        old = input[j];
        count++;
      }
    }
    cout << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<sstream>
#include<iomanip>
#include<stdlib.h>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<utility>
using namespace std;
#define loop(i,l,r) for(int (i)=(int)(l);(i)<(int)(r);(i)++)
#define rloop(i,l,r) for(int (i)=(int)(l);(i)>(int)(r);(i)--)
#define rep(i,n) loop(i,0,n)
#define rrep(i,n) rloop(i,n-1,-1)
#define INF 0x3f3f3f3f
#define mod 1000000007
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

vector<string> split(stringstream& ss){
	string str;
	vector<string> res;
	while(ss>>str)res.push_back(str);
	return res;
}

int main(){
	int n,num;
	char table[9][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'}};
	string s;
	cin>>n;
	rep(i,n){
		cin>>s;
		num=0;
		rep(j,s.size()){
			if(s[j+1]=='0'){
				if(s[j]=='0')continue;
				else cout<<table[s[j]-'1'][s[j]-'1'==0?num%5:s[j]-'1'==6||s[j]-'1'==8?num%4:num%3];
				num=0;
			}else if(s[j+1]==s[j]){
				num++;
			}
		}
		cout<<endl;
	}
}

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

int main(){
  vector<vector<char> > v;
  vector<char> mv;

  mv.push_back(' ');mv.push_back('.');mv.push_back(',');mv.push_back('!');mv.push_back('?');
  v.push_back(mv);
  mv.clear();

  mv.push_back('c');mv.push_back('a');mv.push_back('b');
  v.push_back(mv);
  mv.clear();

  mv.push_back('f');mv.push_back('d');mv.push_back('e');
  v.push_back(mv);
  mv.clear();

  mv.push_back('i');mv.push_back('g');mv.push_back('h');
  v.push_back(mv);
  mv.clear();

  mv.push_back('l');mv.push_back('j');mv.push_back('k');
  v.push_back(mv);
  mv.clear();

  mv.push_back('o');mv.push_back('m');mv.push_back('n');
  v.push_back(mv);
  mv.clear();

  mv.push_back('s');mv.push_back('p');mv.push_back('q');mv.push_back('r');
  v.push_back(mv);
  mv.clear();

  mv.push_back('v');mv.push_back('t');mv.push_back('u');
  v.push_back(mv);
  mv.clear();

  mv.push_back('z');mv.push_back('w');mv.push_back('x');mv.push_back('y');
  v.push_back(mv);
  mv.clear();

  string s;
  int a,i,cou,n,cou2;
  while(cin >> s){ // 入力
    a=s.size();
    //cout <<a<< ' ';//////////////////
    i=0;
    cou2=0;
    while(i<a){//改行まで
      cou=0;
      n=0;
      while(s[i]!='0'&&i<a){//０まで
	if(n!=s[i]-'0')cou=0;
	n=s[i]-'0';
	i++;
	cou++;
      }
      i++;
      //cout <<n<< cou<< ' ';/////////////////
      if(cou!=0&&i<=a){
	if(n==8||n==2||n==3||n==4||n==5||n==6)cou=cou%3;
	else if(n==7||n==9)cou=cou%4;
	else if(n==1)cou=cou%5;

	cout<<v[n-1][cou];
	cou2++;
      }
    }
    if(cou2!=0)cout<<endl;
  }
  return 0;
}