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<vector>
#include<algorithm>
#include<string>
#include<map>

using namespace std;

vector<string>split(string s){
  vector<string>res;
  int pre = 0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0'){
      if(i-pre>0)res.push_back(s.substr(pre,i-pre));
      pre = i+1;
    }
  }
  return res;
}

int main(void){

  map<char,string>mp;
  mp['0']="";
  mp['1']=".,!? ";
  mp['2']="abc";
  mp['3']="def";
  mp['4']="ghi";
  mp['5']="jkl";
  mp['6']="mno";
  mp['7']="pqrs";
  mp['8']="tuv";
  mp['9']="wxyz";
  
  int n;
  cin >> n;

  while(n--){
    string s;
    cin >> s;
    vector<string>res = split(s);
    for(int i=0;i<res.size();i++){
      cout << mp[res[i][0]][(res[i].size()-1)%max(1,(int)mp[res[i][0]].size())];
    }
    cout << endl;
  }
  
  return 0;
}

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

int main(){
  string s;
  int N;
  char bot[10][20]={"0",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; 

  int count=0,flag=0;

  cin>>N;
  for(int i=0;i<N;i++){
    count=0;
    cin>>s;
    for(int j=0;j<(int)s.size();j++){
      if(s[j]!='0'&&flag==0){
	flag=s[j]-'0';
      }else if(flag!=0&&s[j]!='0'){
	count++;
      }else if(s[j]=='0'&&flag!=0){
	if(count<=strlen(bot[flag]))cout<<bot[flag][count];
	else{
	  while(count>strlen(bot[flag])){
	    count=count-strlen(bot[flag]);
	  }
	  cout<<bot[flag][count];
	}
	count=0;
	flag=0;
      }
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

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

void solve() {
	int i = 0;
	int len = (int)S.size();
	
	while (i < len) {
		char c;
		c = S[i++];
		int p = 0;
		
		if (c == '0') continue;
		while (i < len && c == S[i++]) p++;
		
		int id = c - '0';
		string puts =  button[id];
		int size = (int)puts.size();
		cout << puts[p % size];
	}
	
	cout << endl;
}

int main() {
	int n; cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> S;
		solve();
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    char ans[][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'}
    };
    ll n; cin >> n;
    rep(i,n){
        string s(100000,0);
        cin >> s;
        int temp = 0;
        int counter =-1 ;
        for(int k = 0;k<(int)s.size();k++){
            int now = int(s[k]-48);
            if(k == 0){temp = now;counter++;}
            else if(now != 0){
                temp = now;counter++;}
            if(now == 0){
                if(temp  == 9 || temp == 7)
                    counter%=4;
                else if(temp != 1&& temp != 7 && temp!= 9)
                    counter%=3;
                else if(temp == 1)
                    counter %=5;
                if(temp!=0)cout << ans[temp][counter];
                temp = 0;counter =-1;;
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include <string.h>

char cs[10][16] = {
    "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"
};
char s[2000];

int main() {
    int T;
    scanf("%d", &T);
    while (T--) {
        scanf("%s", s);
        int cur = 0, cx = -1;
        for (int i = 0; s[i]; i++) {
            if (s[i] == '0') {
                if (cur != 0) putchar(cs[cur][cx%strlen(cs[cur])]);
                cur = 0;
                cx = -1;
            }
            else {
                cur = s[i] - '0';
                cx++;
            }
        }
        putchar('\n');
    }
    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++;
            }
        }
        if(ans=="") continue;
        cout << ans << endl;
    }
}