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 <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    string s;
    for (int i=0;i<n;i++) {
        cin>>s;
        int j=0;
        while (j<s.size()) {
            int count=0;
            if (s.at(j)=='1') {
                while (s.at(j)!='0') {
                    count++;
                    if (count==6) {
                        count-=5;
                    }
                    j++;
                }
                if (count==1) {
                    cout<<".";
                } else if (count==2) {
                    cout<<",";
                } else if (count==3) {
                    cout<<"!";
                } else if (count==4) {
                    cout<<"?";
                } else if (count==5) {
                    cout<<" ";
                }
            } else if (s.at(j)=='2') {
                while (s.at(j)!='0') {
                    count++;
                    if (count==4) {
                        count-=3;
                    }
                    j++;
                }
                if (count==1) {
                    cout<<"a";
                } else if (count==2) {
                    cout<<"b";
                } else if (count==3) {
                    cout<<"c";
                }
            } else if (s.at(j)=='3') {
                while (s.at(j)!='0') {
                    count++;
                    if (count==4) {
                        count-=3;
                    }
                    j++;
                }
                if (count==1) {
                    cout<<"d";
                } else if (count==2) {
                    cout<<"e";
                } else if (count==3) {
                    cout<<"f";
                }
            } else if (s.at(j)=='4') {
                while (s.at(j)!='0') {
                    count++;
                    if (count==4) {
                        count-=3;
                    }
                    j++;
                }
                if (count==1) {
                    cout<<"g";
                } else if (count==2) {
                    cout<<"h";
                } else if (count==3) {
                    cout<<"i";
                }
            } else if (s.at(j)=='5') {
                while (s.at(j)!='0') {
                    count++;
                    if (count==4) {
                        count-=3;
                    }
                    j++;
                }
                if (count==1) {
                    cout<<"j";
                } else if (count==2) {
                    cout<<"k";
                } else if (count==3) {
                    cout<<"l";
                }
            } else if (s.at(j)=='6') {
                while (s.at(j)!='0') {
                    count++;
                    if (count==4) {
                        count-=3;
                    }
                    j++;
                }
                if (count==1) {
                    cout<<"m";
                } else if (count==2) {
                    cout<<"n";
                } else if (count==3) {
                    cout<<"o";
                }
            } else if (s.at(j)=='7') {
                while (s.at(j)!='0') {
                    count++;
                    if (count==5) {
                        count-=4;
                    }
                    j++;
                }
                if (count==1) {
                    cout<<"p";
                } else if (count==2) {
                    cout<<"q";
                } else if (count==3) {
                    cout<<"r";
                } else if (count==4) {
                    cout<<"s";
                }
            } else if (s.at(j)=='8') {
                while (s.at(j)!='0') {
                    count++;
                    if (count==4) {
                        count-=3;
                    }
                    j++;
                }
                if (count==1) {
                    cout<<"t";
                } else if (count==2) {
                    cout<<"u";
                } else if (count==3) {
                    cout<<"v";
                }
            } else if (s.at(j)=='9') {
                while (s.at(j)!='0') {
                    count++;
                    if (count==5) {
                        count-=4;
                    }
                    j++;
                }
                if (count==1) {
                    cout<<"w";
                } else if (count==2) {
                    cout<<"x";
                } else if (count==3) {
                    cout<<"y";
                } else if (count==4) {
                    cout<<"z";
                }
            }
            j++;
        }
        cout<<endl;
    }
}

C++: // Author :
// Date :
// Problem:
// Solution:
// Comment:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstring>

#define pp push
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

using namespace std;

void play(string str){
    string mas[]={"x",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
    int lng = 0;
    
    for(int i = 0; i < str.size() ; i++){
        if(str[i] == '0'){
            if(lng!=0){
                //cout << (lng-1) << " " << mas[str[i-1]-'0'].size() << endl;
                cout << mas[str[i-1]-'0'][(lng-1)%mas[str[i-1]-'0'].size()] << endl;
                lng = 0;
            }
        }
        else lng++;
    }       
}

main(){
    //freopen("2006-input.txt","r",stdin);
    
    int t;
    string str;
    
    cin >> t;
    
    while(t--){
        cin >> str;
        
        play(str);
    }
    #ifdef GEREL
        for(;;);
    #endif

    return 0;
}