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<string>
using namespace std;
int main(void){
	int n;
	cin>>n;
	string b[9]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	for(int j=0;j<n;j++){
		string s;
		cin>>s;
		int a=-1,time=0;
		string m;
		for(int i=0;i<s.size();i++){
			if(a==s[i]-'1'){
				time++;
			}else if(s[i]=='0'){
				if(a!=-1){
					time%=b[a].size();
					m=b[a][time];
					cout<<m;
					a=-1;
					time=0;
				}
			}else{
				time=0;
				a=s[i]-'1';
			}

		}
		cout<<endl;

	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double EPS = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

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

int main() {
	// cin.tie(0); // tie
	// ios::sync_with_stdio(false); // sync
	cin >> n;
	rep(i, n) {
		cin >> s;
		int num = s[0] - '0', cnt = 0;
		REP(j, 1, s.size()) {
			if (s[j] != s[j - 1] || num == 0) {
				if (num != 0) cout << table[num][cnt];
				cnt = 0;
				num = s[j] - '0';
			} else {
				cnt = (cnt + 1) % table[num].size();
			}
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

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

C++: #include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
        vector<char> c[10];
        c[1]={'.', ',', '!', '?', ' '};
        char cur='a';
        For(i, 2, 10){
                rep(j, i==7 || i==9 ? 4 : 3){
                        c[i].push_back(cur);
                        ++cur;
                }
        }
        int q;
        scanf("%d", &q);
        while(q--){
                string s;
                cin>>s;
                int n=s.size();
                string t;
                int l=0;
                while(l<n){
                        if(s[l]=='0'){
                                ++l;
                                continue;
                        }
                        int r=l;
                        while(r<n && s[l]==s[r]) ++r;
                        t+=c[s[l]-'0'][(r-l-1)%(int)c[s[l]-'0'].size()];
                        l=r;
                }
                cout << t << "\n";
        }
}

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

int main(){
    int n;
    string input;
    string output;
    string phone[10] =
    {
        " ",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"
    };
    int p;
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> input;
        output = "";
        p = input.find('0');
        while(p != string::npos){
            switch(input[0]){
                case '1':
                output += phone[1][(p-1)%5];
                break;
                case '2':
                output += phone[2][(p-1)%3];
                break;
                case '3':
                output += phone[3][(p-1)%3];
                break;
                case '4':
                output += phone[4][(p-1)%3];
                break;
                case '5':
                output += phone[5][(p-1)%3];
                break;
                case '6':
                output += phone[6][(p-1)%3];
                break;
                case '7':
                output += phone[7][(p-1)%4];
                break;
                case '8':
                output += phone[8][(p-1)%3];
                break;
                case '9':
                output += phone[9][(p-1)%4];
                break;
            }
            input.erase(input.begin(), input.begin() + p + 1);
            p = input.find('0');
        }
        cout << output << endl;
    }
}