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 <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;


int main() {
	vector<string> dig = { ".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz" };
	vector<int> cn = { 5,3,3,3,3,3,4,3,4 };
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	REP(j, n) {
		string s;
		cin >> s;

		int i = 0;
		while (i < s.size()) {
			char c = s[i];
			++i;
			if (c != '0') {
				int cnt = 0;
				while (s[i] == c) {
					cnt++;
					++i;
				}
				cout << dig[int(c - '0') - 1][cnt%cn[int(c - '0') - 1]];
			}
		}
		cout << endl;
	}
	
	return 0;
}

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

#define rep(i,n)	for(int i=0;i<n;i++)

int main() {
	string s1 = ".,!? ", s2 = "abc", s3 = "def", s4 = "ghi",
		s5 = "jkl", s6 = "mno", s7 = "pqrs", s8 = "tuv", s9 = "wxyz";
	int n;
	cin >> n; 
	rep(i, n) {
		string str;
		cin >> str;
		int j = 0;
		int p = -114;
		while (j < str.size()) {
			int cnt = 0;
			while (true) {
				if (p != str[j])cnt = 0;
				p = str[j];
				if (str[j] - '0' == 0)break;
				j++;
				cnt++;
			}
			if (j == 0) {
				j++;
				continue;
			}
			switch (str[j - 1] - '0') {
			case 1: cout << s1[(cnt - 1) % s1.size()];
				break;
			case 2: cout << s2[(cnt - 1) % s2.size()];
				break;
			case 3: cout << s3[(cnt - 1) % s3.size()];
				break;
			case 4: cout << s4[(cnt - 1) % s4.size()];
				break;
			case 5: cout << s5[(cnt - 1) % s5.size()];
				break;
			case 6: cout << s6[(cnt - 1) % s6.size()];
				break;
			case 7: cout << s7[(cnt - 1) % s7.size()];
				break;
			case 8: cout << s8[(cnt - 1) % s8.size()];
				break;
			case 9: cout << s9[(cnt - 1) % s9.size()];
				break;
			default:
				break;
			}
			j++;
		}
		cout << endl;
	}
}

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

int main()
{
	int n, c;
	string key[] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	string input;
	char p;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> input;
		c = 0;
		p = '0';
		for (int j = 0; j < input.size(); j++) {
			if (input[j] == '0' && p != '0') {
				cout << key[p - '0'][(c - 1) % key[p - '0'].size()];
				c = 0;
			} else if (input[j] == p) {
				c++;
			} else {
				c = 1;
			}
			p = input[j];
		}
		cout << 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;

  cin>>N;
  for(int i=0;i<N;i++){
    count=0;
    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])){
	    count=count-strlen(bot[flag]);
	  }
	  cout<<bot[flag][count];
	}
	count=0;
	flag=0;
      }
    }
    cout<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<math.h>
#include <string>
#include <stack>
#include<stdio.h>
#include <queue> 
#include <functional>
#define rep(i,n) for (int i=0; i < (int)(n); i++)

using namespace std;

int main(){
	
	stack<int> st; // スタックを宣言＋初期化
	
	int a,b,c,d,e,num;
	int i,j,k;
	int arr[100];
	int arr2[100][100];
	char x,y,z;
	char crr[100];
	char crr2[100][100];
	string str2;
	string str;
	stack<int> istk; // 整数値を格納するスタックを宣言
    stack<string> sstk; // 文字列を格納するスタックを宣言	
	queue<int> ique; // 整数値を格納するキューを宣言
    queue<string> sque; // 文字列を格納するキューを宣言

	
	
	cin >> num;
	
	rep(i , num){
		
		
		cin >> str;
		

		
		j = 0;
		
		
		while(1){
			
			x = NULL;
			
			if(str[j] == NULL) break;
		
			switch(str[j]){
				
				case '0':
				
				j=j+1;
					break;
					
					
	
				case '1':
				
				
				x = '.';
				j = j+1;
				while(1){
					if(str[j] == '0') break;
					if(x == '.' ) x = ',';
					else if(x == ',' ) x = '!';
					else if(x == '!' ) x = '?';
					else if(x == '?' ) x = ' ';
					else x = '.';
					j = j+1;
				}
				j = j+1;
					break;
					
				case '2':
				
				
				x = 'a';
				j = j+1;
				while(1){
					if(str[j] == '0') break;
					if(x == 'a' ) x = 'b';
					else if(x == 'b' ) x = 'c';
					else x = 'a';
					j = j+1;
				}
				j = j+1;
					break;
				case '3':
				
				
				x = 'd';
				j = j+1;
				while(1){
					if(str[j] == '0') break;
					if(x == 'd' ) x = 'e';
					else if(x == 'e' ) x = 'f';
					else x = 'd';
					j = j+1;
				}
				j = j+1;
					break;
				case '4':
				
				
				x = 'g';
				j = j+1;
				while(1){
					if(str[j] == '0') break;
					if(x == 'g' ) x = 'h';
					else if(x == 'h' ) x = 'i';
					else x = 'g';
					j = j+1;
				}
				j = j+1;
					break;
				case '5':
				
				
				x = 'j';
				j = j+1;
				while(1){
					if(str[j] == '0') break;
					if(x == 'j' ) x = 'k';
					else if(x == 'k' ) x = 'l';
					else x = 'j';
					j = j+1;
				}
				j = j+1;
					break;
				case '6':
				
				
				x = 'm';
				j = j+1;
				while(1){
					if(str[j] == '0') break;
					if(x == 'm' ) x = 'n';
					else if(x == 'n' ) x = 'o';
					else x = 'm';
					j = j+1;
				}
				j = j+1;
					break;
				case '7':
				
				
				x = 'p';
				j = j+1;
				while(1){
					if(str[j] == '0') break;
					if(x == 'p' ) x = 'q';
					else if(x == 'q' ) x = 'r';
					else if(x == 'r' ) x = 's';
					else x = 'p';
					j = j+1;
				}
				j = j+1;
					break;
				case '8':
				
				
				x = 't';
				j = j+1;
				while(1){
					if(str[j] == '0') break;
					if(x == 't' ) x = 'u';
					else if(x == 'u' ) x = 'v';
					else x = 't';
					j = j+1;
				}
				j = j+1;
					break;
				case '9':
				
				
				x = 'w';
				j = j+1;
				while(1){
					if(str[j] == '0') break;
					if(x == 'w' ) x = 'x';
					else if(x == 'x' ) x = 'y';
					else if(x == 'y' ) x = 'z';
					else x = 'w';
					j = j+1;
				}
				j = j+1;
					break;

			}
			
//			str2[k] = x;
//			k = k+1;
			if(x == NULL ) continue; 
			cout << x;		

				
				
		}
		
		cout << endl;
		
		
		
	}
		
	return 0;
		
}