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 <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    vector<string> v = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv",
                        "wxyz"};
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        int cur = 0;
        string ans;
        while(cur < s.size()){
            while(s[cur] != '0'){
                int cur2 = cur;
                while(s[cur] == s[cur2+1]) cur2++;
                ans += v[s[cur]-'1'][(cur2-cur)%v[s[cur]-'1'].size()];
                cur = cur2+1;
            }
            cur++;
        }
        cout << ans << "\n";
    }
    return 0;
}

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

using namespace std;

int main()
{
    string messages[9]= {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        string msg;
        string output = "";
        int count = 0;
        char buf;

        cin >> msg;

        for (int j = 0; j < (int)msg.size(); j++) {
            char c = msg[j];

            if (c == '0' && j != 0) {
                if (buf == '1') {
                    output += messages[0][(count-1) % 5];
                } else if (buf == '2') {
                    output += messages[1][(count-1) % 3];
                } else if (buf == '3') {
                    output += messages[2][(count-1) % 3];
                } else if (buf == '4') {
                    output += messages[3][(count-1) % 3];
                } else if (buf == '5') {
                    output += messages[4][(count-1) % 3];
                } else if (buf == '6') {
                    output += messages[5][(count-1) % 3];
                } else if (buf == '7') {
                    output += messages[6][(count-1) % 4];
                } else if (buf == '8') {
                    output += messages[7][(count-1) % 3];
                } else if (buf == '9') {
                    output += messages[8][(count-1) % 4];
                }
                count = 0;
                buf = '0';
            } else {
                count++;
                buf = msg[j];
            }
        }
        cout << output << endl;
    }

    return 0;
}

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

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

void solve() {
	string line;
	cin >> line;
	char pre;
	int count = -1;
	for (unsigned i = 0; i < line.size(); ++i) {
		if (line[i] == '0') {
			int key = pre - '0';
			if (key == 0) continue;
			int index = count % button[key].size();
			cout << button[key][index];
			count = -2;
		}
		count++;
		pre = line[i];
	}
	cout << endl;
}

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

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

using namespace std;

int main()
{
    string messages[9]= {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        string msg;
        string output = "";
        int count = 0;
        char prev = '0';

        cin >> msg;

        for (int j = 0; j < (int)msg.size(); j++) {
            char c = msg[j];

            if (c == '0' && j != 0) {
                if (prev == '1') {
                    output += messages[0][(count-1) % 5];
                } else if (prev == '2') {
                    output += messages[1][(count-1) % 3];
                } else if (prev == '3') {
                    output += messages[2][(count-1) % 3];
                } else if (prev == '4') {
                    output += messages[3][(count-1) % 3];
                } else if (prev == '5') {
                    output += messages[4][(count-1) % 3];
                } else if (prev == '6') {
                    output += messages[5][(count-1) % 3];
                } else if (prev == '7') {
                    output += messages[6][(count-1) % 4];
                } else if (prev == '8') {
                    output += messages[7][(count-1) % 3];
                } else if (prev == '9') {
                    output += messages[8][(count-1) % 4];
                }
                count = 0;
            } else {
                count++;
            }
            prev = msg[j];
        }
        cout << output << endl;
    }

    return 0;
}

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

char table[9][6] = {
	{'.',',','!','?',' '} , // 5
	{'a','b','c','0','0'} ,
	{'d','e','f','0','0'} ,
	{'g','h','i','0','0'} ,
	{'j','k','l','0','0'} ,
	{'m','n','o','0','0'} ,
	{'p','q','r','s','0'} , // 4
	{'t','u','v','0','0'} ,
	{'w','x','y','z','0'} // 4
} ;

int main(){
	
	int n ;
	string s ;
	
	cin >> n ;
	for( int i=0 ; i<n ; i++ ){
		cin >> s ;
		for( int j=0 ; j<s.size() ; j++ ){
			int cnt = 0 , p = 3 ;
			char a = s[j] ;
			if( a == '0' ) continue ;
			if( a == '1' ) p = 5 ;
			if( a == '6' || a == '8' ) p = 4 ;
			for( j+=1 ; j<s.size() ; j++ ){
				if( s[j] == a ) cnt++ ;
				if( s[j] == '0' ) break ;
			}
			cout << table[a-'0'-1][cnt%p] ;
		}
		cout << endl ;
	}
	
return 0 ;
}