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>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int T;
string S;

int mod[10] = { 1, 5, 3, 3, 3, 3, 3, 4, 3, 4 };
char key[10][5] = {
  { '0', '0', '0', '0', '0' },
  { '.', ',', '!', '?', ' ' },
  { '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' },
  { 't', 'u', 'v', '0', '0' },
  { 'w', 'x', 'y', 'z', '0' },
};

int main(void) {
  cin >> T;
  while(T--) {
    cin >> S;
    string ans = "";
    REP(i, 0, S.length()) {
      if(S[i] == '0') continue;
      int j;
      for(j = i; S[j] != '0'; j++);
      int n = S[i] - '0';
      int p = (j - i - 1) % mod[n];
      int k = key[n][p];
      ans += k;
      i = j;
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

int main(){
	vector<string> button;
	button.push_back(".,!?");
	button.push_back("abc");
	button.push_back("def");
	button.push_back("ghi");
	button.push_back("jkl");
	button.push_back("mno");
	button.push_back("pqrs");
	button.push_back("tuv");
	button.push_back("wxyz");

	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		string s;
		string ret;
		cin >> s;
		char current = s[0];
		int count = 0;
		for (int unsigned i = 0; i < s.size(); i++){
			if (s[i] == '0'){
				if (count == 0) continue;
 				int it = (int)(current - '0') - 1;
				cout << button[it][(count -1) % button[it].size()];
				count = 0;
			}
			else {
				current = s[i];
				count++;
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;

int main(){

  int n;
  
  cin >> n;
  
  for(int i = 0;i < n;++i){
	string num;
	cin >> num;
	
	char m = '1';
	
	for(int j = 0;j < num.size();++j){
	  int nn = num[j] - '0';
	  
	  if(nn == 1){
		if(m == '1' || m == ' ')
		  m = '.';
		else if(m == '.')
		  m = ',';
		else if(m == ',')
		  m = '!';
		else if(m == '!')
		  m = '?';
		else if(m == '?')
		  m = ' ';
	  }
	  else if(nn == 2){
		if(m == '1' || m == 'c')
		  m = 'a';
		else if(m == 'a')
		  m = 'b';
		else if(m == 'b')
		  m = 'c';
	  }
	  else if(nn == 3){
		if(m == '1' || m == 'f')
		  m = 'd';
		else if(m == 'd')
		  m = 'e';
		else if(m == 'e')
		  m = 'f';
	  }
	  else if(nn == 4){
		if(m == '1' || m == 'i')
		  m = 'g';
		else if(m == 'g')
		  m = 'h';
		else if(m == 'h')
		  m = 'i';
	  }
	  else if(nn == 5){
		if(m == '1' || m == 'l')
		  m = 'j';
		else if(m == 'j')
		  m = 'k';
		else if(m == 'k')
		  m = 'l';
	  }
	  else if(nn == 6){
		if(m == '1' || m == 'o')
		  m = 'm';
		else if(m == 'm')
		  m = 'n';
		else if(m == 'n')
		  m = 'o';
	  }
	  else if(nn == 7){
		if(m == '1' || m == 's')
		  m = 'p';
		else if(m == 'p')
		  m = 'q';
		else if(m == 'q')
		  m = 'r';
		else if(m == 'r')
		  m = 's';
	  }
	  else if(nn == 8){
		if(m == '1' || m == 'v')
		  m = 't';
		else if(m == 't')
		  m = 'u';
		else if(m == 'u')
		  m = 'v';
	  }
	  else if(nn == 9){
		if(m == '1' || m == 'z')
		  m = 'w';
		else if(m == 'w')
		  m = 'x';
		else if(m == 'x')
		  m = 'y';
		else if(m == 'y')
		  m = 'z';
	  }
	  else if(nn == 0){
		if(m != '1')
		  cout << m;
		m = '1';
	  }
	}
	cout << endl;	
  }
  
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    string botun[] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
 
        string ans=""; 
        int btn=0,count=0;
        for(int j=0;j<s.size();j++){
            if(btn ==0 &&(int)s[j]>0){
                btn=s[j]-'0';
                count=0;
            }else if(btn==(int)s[j]-'0'){
                count++;
            }else if((int)s[j]-'0'==0&&btn>0){
                ans += botun[btn][count % botun[btn].size()];
                btn=0;
                count=0;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<bitset>
#include<map>
using namespace std;

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


string s;
bool input(){
  s="";
  if(!(cin>>s)){
    return false;
  }
  return true;
}


string solve(){
  string res = "";
  int n=-1;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0'){
      if(n==-1||i==0)continue;
      int tmp = s[i-1]-'0';
      res += list[tmp-1][n%list[tmp-1].size()];
      n=-1;
    }else{
      n++;
    }
  }
  return res;
}

int main(){
  int c;
  cin>>c;
  for(int i=0;i<c;i++){
    input();
    string ans = solve();
    if(ans.size()!=0)cout<<ans<<endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){

  int m;
  cin>>m;
  REP(i,m){
    string str;
    int num[1000]={0};
    char now;
    int out=0;
    char one[5]={'.',',','!','?',' '};
    cin >> str;
    int hoge = str.size();
    REP(i,hoge){
      num[i] = str[i] - '0';
    };
    REP(c,hoge){
      int k=0;
      if(num[c]==1){
	while(num[c]==1){
	  k++;
	  c++;
	}
	out=(k+4)%5;
	cout << one[out];
      }else if(num[c]==2){
	while(num[c]==2){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 'a'+out;
	cout << now;
      }else if(num[c]==3){
	while(num[c]==3){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 'd'+out;
	cout << now;
      }else if(num[c]==4){
	while(num[c]==4){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 'g'+out;
	cout << now;
      }else if(num[c]==5){
	while(num[c]==5){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 'j'+out;
	cout << now;
      }else if(num[c]==6){
	while(num[c]==6){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 'm'+out;
	cout << now ;
      }else if(num[c]==7){
	while(num[c]==7){
	  k++;
	  c++;
	}
	out=(k+3)%4;
	now = 'p'+out;
	cout << now;
      } else if(num[c]==8){
	while(num[c]==8){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 't'+out;
	cout << now;
      }else if(num[c]==9){
	while(num[c]==9){
	  k++;
	  c++;
	}
	out=(k+3)%4;
	now = 'w'+out;
	cout << now;
      }
    }
      cout << endl;
  }}