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 <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


vector<pair<char, ll>> RLE(string& s) {
	ll cnt = 0;
	vector<pair<char, ll>> res;
	for (ll i = 0; i < s.size(); i++) {
		cnt++;
		if (i == (ll)s.size() - 1) {
			res.push_back(make_pair(s[i], cnt));
			break;
		}
		if (s[i] != s[i + 1]) {
			res.push_back(make_pair(s[i], cnt));
			cnt = 0;
		}
	}
	return res;
}

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	ll n; scanf("%lld", &n);
	vector<vector<char>> c(11);
	c[1] = { '.',',','!','?',' ' };
	c[2] = { 'a','b','c' };
	c[3] = { 'd','e','f' };
	c[4] = { 'g','h','i' };
	c[5] = { 'j','k','l' };
	c[6] = { 'm','n','o' };
	c[7] = { 'p','q','r','s' };
	c[8] = { 't','u','v' };
	c[9] = { 'w','x','y','z' };
	while (n--) {
		string s; cin >> s;
		vector<pair<char, ll>> vp = RLE(s);
		string res;
		for (auto p : vp) {
			if (p.first == '0') continue;
			ll cnt = (p.second - 1) % c[p.first - '0'].size();
			res += c[p.first - '0'][cnt];
		}
		cout << res << "\n";
	}
	return 0;
}

C++: a

C++: #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  char m[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'}};

  int a,count=0,c[100],d;
  char b[100][1024];
  cin>>a;

  for(int i=0;i<a;i++){
    scanf("%s",b[i]);
    c[i]=strlen(b[i]);
    for(int j=0;j<c[i];j++){
      if(b[i][j]!='0')count++;
      else
	if(b[i][j-1]!=0){
	  d=(int)(b[i][j-1])-48;

	  if(d==1)
	    if(count%5!=0)
	      cout<<m[d-1][count%5-1];
	    else cout<<m[d-1][4];

	  else if(d==7 || d==9)
	    if(count%4!=0)
	      cout<<m[d-1][count%4-1];
	    else cout<<m[d-1][3];

	  else
	    if(count%3!=0)
	      cout<<m[d-1][count%3-1];
	    else cout<<m[d-1][2]; 
	  count=0;
	}
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;

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

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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;



int main(){
    string s;
    vector<string> a(10);
    a[1] = ".,!?";
    a[2] = "abc";
    a[3] = "def";
    a[4] = "ghi";
    a[5] = "jkl";
    a[6] = "mno";
    a[7] = "pqrs";
    a[8] = "tuv";
    a[9] = "wxyz";

    while(cin>>s){
        int n=s.size();
        string ans;
        int cnt=0;
        rep(i,n){
            if(cnt==0 and s[i]=='0') continue;
            if(s[i]=='0'){
                int idx = s[i-1]-'0';
                cnt--;
                cnt %= a[idx].size();
                ans.push_back(a[idx][cnt]);
                cnt = 0;
            }else{
                cnt++;
            }
        }
        cout << ans << endl;
    }
}