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 <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
int main(void){
    vector<string> str(9);
    str[0]=".,!? ";
    str[1]="abc";
    str[2]="def";
    str[3]="ghi";
    str[4]="jkl";
    str[5]="mno";
    str[6]="pqrs";
    str[7]="tuv";
    str[8]="wxyz";
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string x;
        string ans="";
        cin >> x;
        int count;
        if(x[0]!='0'){
            count=1;
        }else{
            count=0;
        }
        
        for(int j=1;j<x.length();j++){
            if(x[j]=='0'){
                if(x[j-1]!='0'){
                    if(count > str[(x[j-1]-'0')-1].length()){
                        count = count%str[(x[j-1]-'0')-1].length();
                        if(count == 0){
                            count =str[(x[j-1]-'0')-1].length();
                        }
                    }
                    ans+=str[(x[j-1]-'0')-1][count-1];
                }
                count=0;
            }else{
                count++;
            }
        }
        cout << ans << endl;
    }
}

C++: #include<stdio.h>
#include<iostream>
#include<string>

using namespace std;

int main(){

	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		string str;
		char last;
		char key[10][13]={
			{' '},
			{' ','.',',','!','?',' '},
			{' ','a','b','c','a','b','c','a','b','c','a','b','c'},
			{' ','d','e','f','d','e','f','d','e','f','d','e','f'},
			{' ','g','h','i','g','h','i','g','h','i','g','h','i'},
			{' ','j','k','l','j','k','l','j','k','l','j','k','l'},				
			{' ','m','n','o','m','n','o','m','n','o','m','n','o'},
			{' ','p','q','r','s','p','q','r','s','p','q','r','s'},
			{' ','t','u','v','t','u','v','t','u','v','t','u','v'},
			{' ','w','x','y','z','w','x','y','z','w','x','y','z'},								
		};
		cin >> str;
		int array[10],i;
		for(i=0;i<10;i++){
			array[i]=0;
		}
		last = str[0];
		for(i=0;i<str.size();i++){
			array[str[i]-0x30]++;
			if(array[str[i]-0x30] > 12 && last!=1) array[str[i]-0x30]=1;
			if(array[1] > 5) array[1]=1;
			if(str[i]=='0' && last!='0'){
				// cout << last << ':' << array[last-0x30] << endl;
				cout <<  key[(last-0x30)][array[last-0x30]];
				for(int l=0;l<10;l++){
					array[l]=0;
				}
			}
			last = str[i];
		}
		cout << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
    vector<string> v;
    v.push_back("");
    v.push_back(".,!? ");
    v.push_back("abc");
    v.push_back("def");
    v.push_back("ghi");
    v.push_back("jkl");
    v.push_back("mno");
    v.push_back("pqrs");
    v.push_back("tuv");
    v.push_back("wxyz");
    string s;
    int n;
    scanf("%d",&n);
    for(int k=0;k<n;k++) {
        cin>>s;
        int num=0,cnt=0;
        for(int i=0;i<s.size();i++) {
            if(s[i]=='0') {
                if(num) putchar(v[num][(cnt-1)%v[num].size()]);
                num=cnt=0;
            }else {
                num=s[i]-'0';
                cnt++;
            }
        }
        putchar('\n');
    }
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	while(n--){
		string s; cin >> s;
		string t[] = {" ", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
		string res = "";
		int cnt = 0, idx = 0;
		for(int i=0;i<s.size();i++){
			if(s[i]=='0'){
				if(idx!=0){
					res += t[idx][cnt];
				}
			}
			if(idx == s[i]-'0'){
				cnt = (cnt+1)%t[idx].size();
			} else {
				cnt = 0;
			}
			idx = s[i]-'0';
		}
		cout << res << endl;
	}
}

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

void Show_message(char button, int num)
{
  switch(button)
  {
    case '1':
      switch(num % 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(num % 3)
      {
        case 1:
          cout << 'a'; break;
        case 2:
          cout << 'b'; break;
        case 0:
          cout << 'c'; break;
      }
      break;
    case '3':
      switch(num % 3)
      {
        case 1:
          cout << 'd'; break;
        case 2:
          cout << 'e'; break;
        case 0:
          cout << 'f'; break;
      }
      break;
    case '4':
      switch(num % 3)
      {
        case 1:
          cout << 'g'; break;
        case 2:
          cout << 'h'; break;
        case 0:
          cout << 'i'; break;
      }
      break;
    case '5':
      switch(num % 3)
      {
        case 1:
          cout << 'j'; break;
        case 2:
          cout << 'k'; break;
        case 0:
          cout << 'l'; break;
      }
      break;
    case '6':
      switch(num % 3)
      {
        case 1:
          cout << 'm'; break;
        case 2:
          cout << 'n'; break;
        case 0:
          cout << 'o'; break;
      }
      break;
    case '7':
      switch(num % 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(num % 3)
      {
        case 1:
          cout << 't'; break;
        case 2:
          cout << 'u'; break;
        case 0:
          cout << 'v'; break;
      }
      break;
    case '9':
      switch(num % 4)
      {
        case 1:
          cout << 'w'; break;
        case 2:
          cout << 'x'; break;
        case 3:
          cout << 'y'; break;
        case 0:
          cout << 'z'; break;
      }
      break;
  }
}

int main(void)
{
  int n;
  cin >> n;
  char buf_ch;
  cin >> noskipws;
  cin >> buf_ch;
  for (int i = 0; i < n; ++i)
  {
    while (true)
    {
      cin >> buf_ch;
      if (buf_ch == '\n') break;
      if (buf_ch == '0') continue;

      int sum = 1;
      char button = buf_ch;
      while (true)
      {
        cin >> buf_ch;
        if (buf_ch == '0')
        {
          Show_message(button, sum);
          break;
        }
        else
        {
          ++sum;
        }
      }
    }
    cout << endl;
  }
  return 0;
}