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++: //#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

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

int main()
{
    int n;
    cin >> n;
    rep(i, n) {
        string s;
        cin >> s;
        string ans = "";
        int cnt = 0;
        int d = 0;
        rep(j, s.size()) {
            if(s[j]=='0') {
                if(d==1) cnt = (cnt-1)%5;
                else if(d==7||d==9) cnt = (cnt-1)%4;
                else cnt = (cnt-1)%3;
                ans += keys[d][cnt];
                cnt = 0;
                d = 0;
            }
            else {
                d = s[j] - '0';
                cnt++;
            }
        }
        P(ans);
    }
    return 0;
}

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

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

char c2i(char c){return c-'0';}

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

void solve() {
  string s; cin>>s;
  
  int now = 0, count = 0;
  rep(i,s.size()) {
    if (s[i] == '0') {
      if (count == 0) continue;
      count--;
      count %= key[now].size();
      cout<<key[now][count];
      now = count = 0;
    } else {
      if (now == 0) {
        now = c2i(s[i]);
      }
      count++;
    }
  }
  cout<<endl;
}

int main (int argc, char const* argv[]) {
  int n; cin>>n;
  rep(i,n) solve();  
  return 0;
}

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

int main(){
	char symbol[5] = {'.', ',', '!', '?', ' '};
	char ans[80];
	int stringSize = 0;
	char input[2000];
	int count;
	
	cin >> count;
	for(int q=0; q < count; q++){
		stringSize = 0;
		cin >> input;
		int num = 0;
		int numCount = 0;
		for(int i=0; i < (int)strlen(input); i++){
			char tmp = input[i];
			int n = atoi(&tmp);
			if(n == num) numCount++;
			else if(n != num){
				switch(num){
					case 1:
						ans[stringSize++] = symbol[numCount % 5];
						break;
					case 2:
						ans[stringSize++] = 'a' + numCount % 3;
						break;
					case 3:
						ans[stringSize++] = 'd' + numCount % 3;
						break;
					case 4:
						ans[stringSize++] = 'g' + numCount % 3;
						break;
					case 5:
						ans[stringSize++] = 'j' + numCount % 3;
						break;
					case 6:
						ans[stringSize++] = 'm' + numCount % 3;
						break;
					case 7:
						ans[stringSize++] = 'p' + numCount % 4;
						break;
					case 8:
						ans[stringSize++] = 't' + numCount % 3;
						break;
					case 9:
						ans[stringSize++] = 'w' + numCount % 4;
						break;
					case 0:
						break;
				}
				num = n;
				numCount = 0;
			}
		}
		ans[stringSize] = '\0';
		cout << ans << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string str,one=".,!? ",ans;
		cin>>str;
		for(int j=0,co=0,num=0;j<=str.size();j++){
			if(num==str[j]-'0')co++;
			else{
				if(num==1)ans+=one[(co-1)%5];
				else if(num<9&&num>1)ans+=(co-1)%3+'a'*(num-1);
				else if(num>1)ans+=(co-1%4)+'w';
				co=1;
				num=str[j]-'0';
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<ll,ll,ll,ll> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	while(cin>>n,n){
		int co=0;
		rep(i,n)loop(j,i+1,n+1)if((i+j)*(j-i+1)/2==n)co++;
		cout<<co<<endl;
	}
}

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

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

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