Go: // Keitai Message
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2006&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)

	for i := 0; i < n; i++ {
		message := nextString(sc)
		currentButton, count := 0, 0
		for _, word := range message {
			// 確定の処理を書く
			if word == '0' {
				if currentButton == 0 {
					count = 0
					continue
				}
				mod := len(table[currentButton])
				tmp := table[currentButton][(count-1)%mod]
				currentButton, count = 0, 0
				fmt.Printf("%c", tmp)
			} else {
				count++
				currentButton = int(word) - 48 // '0'はASCIIで48
			}
		}
		fmt.Println()
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

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

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

string solve(){
  string t = "";

  int key=0, cnt=0;
  for(int i=0; i<(int)s.size(); i++){
    int S = s[i] - '0';
    if(S==0){
      if(key!=0){
        cnt--;
        int len=a[key].size();
        t.push_back(a[key][cnt%len]);
      }
      cnt=key=0;
    } else if(key==S){
      cnt++;
    } else {
      key=S;
      cnt=1;
    }
  }
  return t;
}

int main(){
  int n;
  cin >> n;
  while(n--){
    cin >> s;
    cout << solve() << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <typeinfo>
#include <cxxabi.h>
#define type_name(class)  demangle((typeid(class)).name())
char* demangle(const char *demangle) {
    int status;
    return abi::__cxa_demangle(demangle, 0, 0, &status);
}

using namespace std;

class ButtonForwarder{
private:
	string m_chars;
	int m_nchars;
	unsigned int m_pos;
public:
	ButtonForwarder(){}
	ButtonForwarder(const string& str){
		m_chars = str;
		m_nchars = str.size();
		m_pos = -1;
	} 
	~ButtonForwarder(){}
	void push_button(){
		if(m_pos == m_nchars-1){
			m_pos = 0;
		}else{
			m_pos++;
		}
	}
	const string getCharacter(){
		// cout<<"In getCharacter() string is "<<m_chars<<endl;
		// cout<<"m_pos = "<<m_pos<<endl;
		return m_chars.substr(m_pos,1);
	}
	void reset(){m_pos=-1;}
};

class CellularKeyboard{
private:
	map<string, ButtonForwarder> m_buttons;
	string m_curButton;
	string result_temp;
public:
	CellularKeyboard(){m_curButton="";result_temp="";}
	void setStrings(string button, string chars){
		ButtonForwarder bf(chars);
		m_buttons[button] = bf;
	}
	string push(string button){
		// cout<<"push("<< button <<")"<<endl;
		//確定ボタン(キー0が押された場合)
		if(button == "0"){
			//何もボタンが押されていないときに確定ボタンを押すことはできるが、
			//その場合には何も文字は出力されない。
			if(m_curButton.length()==0){return string("");}
			
			// cout<<m_curButton<<endl;
			result_temp = m_buttons[m_curButton].getCharacter();
			m_buttons[m_curButton].reset();
			m_curButton = "";
			return result_temp;
		}
		m_curButton = button;
		m_buttons[button].push_button();
		// cout<<&(m_buttons[button])<<endl;
		// cout<<"Button"<<button<<" is "<<m_buttons[button].getCharacter()<<endl;
		return string("");
	}
};

int main() {
	// your code goes here
	CellularKeyboard kbd;
	kbd.setStrings(string("1"), string(".,!? "));
	kbd.setStrings(string("2"), string("abc"));
	kbd.setStrings(string("3"), string("def"));
	kbd.setStrings(string("4"), string("ghi"));
	kbd.setStrings(string("5"), string("jkl"));
	kbd.setStrings(string("6"), string("mno"));
	kbd.setStrings(string("7"), string("pqrs"));
	kbd.setStrings(string("8"), string("tuv"));
	kbd.setStrings(string("9"), string("wxyz"));
	
	int num;
	string input, decoded;
	cin>>num;
	for(int n=0;n<num;n++){
		cin>>input;
		decoded="";
		for(int i=0;i<input.length();i++){
			decoded += kbd.push(input.substr(i,1));
		}
		cout<<decoded<<endl;
	}
	
	// string input, decoded;
	// input ="000555555550000330000444000080000200004440000";
	// for(int i=0;i<input.length();i++){
	// 	// cout<<"char : "<<input.substr(i,1)<<" => "<<kbd.push(input.substr(i,1))<<endl;
	// 	decoded += kbd.push(input.substr(i,1));
	// }
	// cout<<decoded<<endl;
	return 0;
}

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

using namespace std;

#define all(i) i.begin(), i.end()
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
	int num = 0; cin >> num;
	string dat[12] = { "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
	rep(i, num)
	{
		string str; cin >> str;
		vector<int> hit(10, 0);
		rep(j, (int)str.size())
		{
			hit[str[j] - '0'] += 1;
			if (j == 0 || str[j - 1] == '0') {}
			else if (str[j] == '0')
			{
				int n = 0, tmp = str[j - 1] - '0';
				n = hit[tmp] % (int)dat[tmp].size();
				if (n == 0){ n = hit[tmp] + 1; }
				if (n >= 3 && (int)dat[tmp].size() == 3) { n -= 1; }
				printf("%c", dat[tmp][n - 1]);
				rep(i, 10){ hit[i] = 0; }
			}
		}
		printf("\n");
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

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


int main()
{

    int n;
    cin >> n;
    string s;
    rep(j,n)
    {
        cin >> s;
        int bnum = 0;
        int pushnum = 0;
        REP(s.size())
        {
            if(s[i] == '0' && pushnum > 0)
            {
                cout << button[bnum][(pushnum + button[bnum].size() - 1) % button[bnum].size()];
                pushnum = 0;
                bnum = 0;
                continue;
            }
            if(s[i] != '0'){ pushnum = (pushnum+1) ; bnum = s[i] - '0'; }
        }
        cout << endl;
    }
    return 0;
}