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 <stdio.h>
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main() {
	int a[1030];
	int k;
	stringstream sout;
	string b;
	int kari;
	int kaka;
	cin >> kaka;
	for  (int j = 0; j < kaka; j++) {
		cin >> b;
		kari = 0;
		int rireki[10] = {0};
		k = b.size();
		for (int i = 0; i < k; i++) {
			sout.str("");
			sout.clear();
			sout << b[i];
			sout >> a[i];
		}
		for (int i = 0; i < k-1; i++) {
			if(a[i] != a[i+1] && a[i+1] == 0 && a[i] != 0) {
				kari = 1;
				if (a[i] == 1) {
					if(rireki[1] % 5 == 0) {
						printf(".");
					} else if (rireki[1] % 5 == 1) {
						printf(",");
					} else if (rireki[1] % 5 == 2) {
						printf("!");
					} else if (rireki[1] % 5 == 3) {
						printf("?");
					} else {
						printf(" ");
					}
					rireki[1] = 0;
				} else if (a[i] == 2) {
					if(rireki[2] % 3 == 0) {
						printf("a");
					} else if (rireki[2] % 3 == 1) {
						printf("b");
					} else {
						printf("c");
					}
					rireki[2] = 0;
				} else if (a[i] == 3) {
					if (rireki[3] % 3 == 0) {
						printf("d");
					} else if (rireki[3] % 3 == 1) {
						printf("e");
					} else {
						printf("f");
					}
					rireki[3] = 0;
				} else if (a[i] == 4) {
					if (rireki[4] % 3 == 0) {
						printf("g");
					} else if (rireki[4] % 3 == 1) {
						printf("h");
					} else {
						printf("i");
					}
					rireki[4] = 0;
				} else if (a[i] == 5) {
					if (rireki[5] % 3 == 0) {
						printf("j");
					} else if (rireki[5] % 3 == 1) {
						printf("k");
					} else {
						printf("l");
					} 
					rireki[5] = 0;
				} else if (a[i] == 6) {
					if (rireki[6] % 3 == 0) {
						printf("m");
					} else if (rireki[6] % 3 == 1) {
						printf("n");
					} else {
						printf("o");
					}
					rireki[6] = 0;
				} else if (a[i] == 7) {
					if (rireki[7] % 4 == 0) {
						printf("p");
					} else if (rireki[7] % 4 == 1) {
						printf("q");
					} else if (rireki[7] % 4 == 2) {
						printf("r");
					} else {
						printf("s");
					}
					rireki[7] = 0;
				} else if (a[i] == 8) {
					if (rireki[8] % 3 == 0) {
						printf("t");
					} else if(rireki[8] % 3 == 1) {
						printf("u");
					} else {
						printf("v");
					}
					rireki[8] = 0;
				} else {
					if (rireki[9] % 4 == 0) {
						printf("w");
					} else if (rireki[9] % 4 == 1) {
						printf("x");
					} else if (rireki[9] % 4 == 2) {
						printf("y");
					} else {
						printf("z");
					}
					rireki[9] = 0;
				}
			} else {
				if (a[i] == 0 || (a[i] != a[i+1])) {
					rireki[a[i]] = 0;
					continue;
				}
				rireki[a[i]]++;
			}
		}
		if (kari == 1) {
			printf("\n");
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> P;

string con[15] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
int main() {
	string s;
	int n;
	cin >> n;
	for(int q = 0; q < n; ++q){
		cin >> s;
		string ans("");
		P cnt;
		cnt.first = cnt.second = 0;
		for(int i = 0; i < s.size(); ++i){
			if(s[i] == '0'){
				int num = cnt.first;
				if(num == 1){
					ans += con[num - 1][cnt.second % 5];
				}
				else if(num == 7 && num == 9){
					ans += con[num - 1][cnt.second % 4];
				}
				else if(num == 0){
					continue;
				}
				else{
					ans += con[num - 1][cnt.second % 3];
				}
				
				cnt.first = cnt.second = 0;
			}
			else{
				if(cnt.first == 0){
					cnt.first = s[i] - '0';
				}
				else{
					cnt.second++;
				}
			}
		}
		cout << ans << 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;
  while(cin>>N){
    for(int i=0;i<N;i++){
      count=0;
      s.clear();
      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])-1){
	      count=count-strlen(bot[flag]);
	    }
	    cout<<bot[flag][count];
	  }
	  count=0;
	  flag=0;
	}
      }
      cout<<endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		
		string key[]={".,!?, ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	}
	return 0;
}

C++: #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>


int main()
{
	int i,j,k;
	int n,m;
	int a[10]={0}; //押された回数
	int b[10]={0,5,3,3,3,3,3,4,3,4}; //割り算	 
	int c; //押されたボタン
	char d[5][10]={
	{'0',' ','c','f','i','l','o','s','v','z'},
	{'0','.','a','d','g','j','m','p','t','w'},
	{'0',',','b','e','h','k','n','q','u','x'},
	{'0','!','0','0','0','0','0','r','0','y'},
	{'0','?','0','0','0','0','0','0','0','0'}};
	char e[1025];
	
	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		scanf("%s",e);
		c=0;
		for(j=0;j<strlen(e);j++)
		{
			if(e[j]=='0'){
				if(c!=0)
				{
					printf("%c",d[a[c]%b[c]][c]);
					a[c]=0;
					c=0;
				}
			}else
			{
				if(e[j]=='1')c=1;
				else if(e[j]=='2')c=2;
				else if(e[j]=='3')c=3;
				else if(e[j]=='4')c=4;
				else if(e[j]=='5')c=5;
				else if(e[j]=='6')c=6;
				else if(e[j]=='7')c=7;
				else if(e[j]=='8')c=8;
				else if(e[j]=='9')c=9;
				a[c]++;
			}
		}
		printf("\n");
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0; }
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0; }

using namespace std;

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

int main(void){
	int n; cin >> n;
	while(n--) {
		string s; cin >> s;
		string res = "";
		int r=0, c=0;
		rep(i,s.size()) {
			if(s[i] == '0') {
				if(r==0) {
					c=0;
					continue;
				}
				else {
					c%=pad[r].size();
					res += pad[r][c];
					r=0, c=0;
				}
			}
			else {
				if(s[i]-'0' == r) c++;
				else r = s[i]-'0';
			}
		}
		cout << res << endl;
	}
	return 0;
}