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>
using namespace std;
int main(){
    int n,b[]={1,5,3,3,3,3,3,4,3,4},m,i;
    string s;
    char tab[20][6]={" ",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
    cin>>n;
    while(cin>>s){
        for(i=m=0;i<s.size();i++)
            if(s[i]=='0'){
                if(m)
                    cout<<tab[s[i-1]-'0'][(m-1)%b[s[i-1]-'0']];
                m=0;
            }else
                m++;
        cout<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> P;
static const int INF=1<<24;

string s[15];

int main(){
	s[1]=".,!?";
	s[2]="abc";
	s[3]="def";
	s[4]="ghi";
	s[5]="jkl";
	s[6]="mno";
	s[7]="pqrs";
	s[8]="tuv";
	s[9]="wxyz";
	
	string st;
	int n;
	cin>>n;
	rep(k,n){
		cin>>st;
		P res(0,0);
		rep(i,st.size()){
			if(st[i]!='0'){
				res.F++;
				res.S=st[i]-'0';
			}
			else if(res.S!=0){
				int t;
				if(res.F==1||res.F==7||res.F==9) t=4;
				else t=3;
				cout<<s[res.S][(res.F-1)%t];
				res.F=0;res.S=0;
			}
		}
		if(res.S!=0){
			int t;
			if(res.F==1||res.F==7||res.F==9) t=4;
			else t=3;
			cout<<s[res.S][(res.F-1)%t];
		}
		cout<<endl;
	}
	
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int n;
string t[10]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		string ans="";
		cin>>s;
		int tt=0;
		for(int i=0;i<s.size();i++){
			if(s[i]!='0'){
				tt++;
			}else{
				if(tt==0)continue;
				char q=s[i-1];
				tt--;
				if(q=='1'){
					ans+=t[(q-'0')][tt%5];
				}else if(q=='7'||q=='9'){
					ans+=t[(q-'0')][tt%4];
				}else{
					ans+=t[(q-'0')][tt%3];
				}
				tt=0;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>

using namespace std;

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

int main() {
    int C;
    cin >> C;

    while (C-- > 0) {
        string s;
        cin >> s;

        int pos = 0;
        string res = "";
        for (int i = 0; i < s.length() - 1; i++) {
            int k = stoi(s.substr(i, 1));
            if (k == 0) {

            } else if (s[i] == s[i + 1]) {
                pos++;
            } else {
                res += keys[k].substr(pos % keys[k].length(), 1);
                pos = 0;
            }
        }

        cout << res << endl;
    }
}

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

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

string solve(){
  string t = "";

  int key=0, cnt=0;
  for(int i=0; i<(int)s.size(); i++){
    int S = s[i] - '0';
    if(S==0){
      if(key!=0){
        cnt--;
        int len=a[key].size();
        t.push_back(a[key][cnt%len]);
      }
      cnt=key=0;
    } else if(key==S){
      cnt++;
    } else {
      key=S;
      cnt=1;
    }
  }
  return t;
}

int main(){
  int n;
  cin >> n;
  while(n--){
    cin >> s;
    cout << solve() << endl;
  }
  return 0;
}

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

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

string solve(){
  string t = "";

  int key=0, cnt=0;
  for(int i=0; i<(int)s.size(); i++){
    int S = s[i] - '0';
    if(S==0){
      if(key!=0){
        cnt--;
        int len=a[key].size();
        t.push_back(a[key][cnt%len]);
      }
      cnt=key=0;
    } else if(key==S){
      cnt++;
    } else {
      key=S;
      cnt=1;
    }
  }
  return t;
}

int main(){
  int n;
  cin >> n;
  while(n--){
    cin >> s;
    cout << solve() << endl;
  }
  return 0;
}

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

char T[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'} };

int C[9] = {5, 3, 3, 3, 3, 3, 4, 3, 4};

int main() {
  int N;
  cin >> N;
  for (int k=0; k<N; k++) {
    string S;
    cin >> S;
    string A = "";
    int now;
    int count = 0;
    for (unsigned int i=0; i<S.size(); i++) {
      int x = (int)S[i] - '0';
      if (x != 0) {
	now = x;
	count++;
      } else if (count > 0){
	A += T[now-1][(count-1)%C[now-1]];
	count = 0;
      }
    }
    cout << A << endl;
  }
}

C++: #include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
struct Data{
    char c;
    int n;
};
int main(void){

    int n;
    cin>>n;
    string str;
    string c[] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    while(n--){
        cin>>str;
        Data a[100];
        char ch = 'A';
        int t = -1;
        for(int i = 0;i < str.size();i++){
            if(ch == str[i]){
                a[t].n++;
            }
            else{
                ch = str[i];
                t++;
                a[t].c = ch;
                a[t].n = 1;
            }
        }
        t++;
        for(int i = 0;i < t;i++){
            if(a[i].c == '0')continue;
            cout<<c[a[i].c - '0' - 1][(a[i].n - 1)%c[a[i].c - '0' - 1].size()];
        }
        cout<<endl;
    }


    return 0;
}