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

char in[1029];
char out[78];

void input(){
  cin >>in;
  cout<<in[1];
}

void solve(){ 
  int count=0;
  int  c=1;
  char p='\0';
  REP(i,78)out[i]=' ';
  for(int i=0;in[i]!='\0';i++){
    switch(in[i]){
      case '1':if(p=='1')c++;
      else p='1';
      break;

      case '2':if(p=='2')c++;
      else p='2';
      break;

      case '3':if(p=='3')c++;
      else p='3';
      break;
            
      case '4':if(p=='4')c++;
      else p='4';
      break;

      case '5':if(p=='5')c++;
      else p='5';
      break;

      case '6':if(p=='6')c++;
      else p='6';
      break;

      case '7':if(p=='7')c++;
      else p='7';
      break;

      case '8':if(p=='8')c++;
      else p='8';
      break;

      case '9':if(p=='9')c++;
      else p='9';
      break;

      case '0':
      if(p=='1'){
        if(c%4==1)out[count]='.';
        else if(c%4==2)out[count]=',';
        else if(c%4==3)out[count]='!';
        else out[count]='?';

      }

      if(p=='2'){
        if(c%3==1)out[count]='a';
        else if(c%3==2)out[count]='b';
        else out[count]='c';
        }

      if(p=='3'){
        if(c%3==1)out[count]='d';
        else if(c%3==2)out[count]='e';
        else out[count]='f';
      }

      if(p=='4'){
        if(c%3==1)out[count]='g';
        else if(c%3==2)out[count]='h';
        else out[count]='i';
      }

      if(p=='5'){
        if(c%3==1)out[count]='j';
        else if(c%3==2)out[count]='k';
        else out[count]='l';
      }

      if(p=='6'){
        if(c%3==1)out[count]='m';
        else if(c%3==2)out[count]='n';
        else out[count]='o';
      }

      if(p=='7'){
        if(c%4==1)out[count]='p';
        else if(c%4==2)out[count]='q';
        else if(c%4==3)out[count]='r';
        else out[count]='s';
      }

      if(p=='8'){
        if(c%3==1)out[count]='t';
        else if(c%3==2)out[count]='u';
        else out[count]='v';
      }

      if(p=='9'){
        if(c%4==1)out[count]='w';
        else if(c%4==2)out[count]='x';
        else if(c%4==3)out[count]='y';
        else out[count]='z';
      }
      p='\0';
      c=1;
      count++;
    }
    out[count]='\0';
   }
   for(int i;out[i]!='\0';i++)cout<<out[i];
   cout<<endl;
}

int main(){
  int n;
  cin>>n;
  REP(i,n){
    input();
    solve();
  }
}

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

int main(){
	string data,word[]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	int num,time,cnt = -1;
	cin >> num;
	num = num + 1;
	while(num--){
		getline(cin,data);
		for(int i = 0;i < data.size();i++){
			char vd = data[i],*point,st;
			if(vd == '0'){
				st = data[i - 1];
				point = &st;
				time = atoi(point);
				if(cnt > 2){
					if(time == 1 || time == 7 || time == 9){
						if(time == 1){
							cnt = cnt % 5;
						}else{
							cnt = cnt % 4;
						}
					}else{
						cnt = cnt % 3;
					}
				}
				cout << word[time][cnt];
				cnt = -1;
			}else{
			cnt++;
			}
		}
		cout << endl;
	}
	return 0;
}

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

int main(int argc, char const* argv[])
{
  char assignments[][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 n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::string s;
    std::cin >> s;
    for (std::string::const_iterator it = s.begin(); it != s.end(); ++it) {
      int key = (*it) - '0';
      if (key == 0) {
        continue;
      }
      int x = 0;
      for (; *it != '0'; ++it) {
        ++x;
      }
      --x;
      int a;
      if (key == 1)
        a = 5;
      else if (key == 7 || key == 9)
        a = 4;
      else
        a = 3;
      std::cout << assignments[key][x % a];
    }
    std::cout << std::endl;
  }
  return 0;
}

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

typedef pair<char, int> P;
vector<P> v;

char N2C(char num, int cnt){
	if(num == '1'){
		if(cnt % 4 == 1) return ' ';
		else if(cnt % 4 == 2) return ',';
		else if(cnt % 4 == 3) return '!';
		else if(cnt % 4 == 0) return '?';
	}
	else if(num == '2'){
		if(cnt % 3 == 1) return 'a';
		else if(cnt % 3 == 2) return 'b';
		else if(cnt % 3 == 0) return 'c';
	}
	else if(num == '3'){
		if(cnt % 3 == 1) return 'd';
		else if(cnt % 3 == 2) return 'e';
		else if(cnt % 3 == 0) return 'f';
	}
	else if(num == '4'){
		if(cnt % 3 == 1) return 'g';
		else if(cnt % 3 == 2) return 'h';
		else if(cnt % 3 == 0) return 'i';
	}
	else if(num == '5'){
		if(cnt % 3 == 1) return 'j';
		else if(cnt % 3 == 2) return 'k';
		else if(cnt % 3 == 0) return 'l';
	}
	else if(num == '6'){
		if(cnt % 3 == 1) return 'm';
		else if(cnt % 3 == 2) return 'n';
		else if(cnt % 3 == 0) return 'o';
	}
	else if(num == '7'){
		if(cnt % 4 == 1) return 'p';
		else if(cnt % 4 == 2) return 'q';
		else if(cnt % 4 == 3) return 'r';
		else if(cnt % 4 == 0) return 's';
	}
	else if(num == '8'){
		if(cnt % 3 == 1) return 't';
		else if(cnt % 3 == 2) return 'u';
		else if(cnt % 3 == 0) return 'v';
	}
	else if(num == '9'){
		if(cnt % 4 == 1) return 'w';
		else if(cnt % 4 == 2) return 'x';
		else if(cnt % 4 == 3) return 'y';
		else if(cnt % 4 == 0) return 'z';
	}
	else return 'A';
}

int main(){
	int n;
	cin >> n;
for(int i=0; i<n; i++){	
	
	string s;
	cin >> s;
	int len = s.size();
	
	int head = 0;
	for(int i=0; i < len; i++){
		if(s[i] == '0') head++;
		else break;
	}
	
	
	int body = -1;
	for(int i=head; i<len; i++){
		body++;
		if(s[i] == '0'){
			if(s[i-1] != '0'){
				v.push_back(P(s[i-1], body));
			}
			body = -1;
		}
	}
	
	for(int i=0; i<(int)v.size(); i++){
		if(N2C(v[i].first, v[i].second) == 'A') continue;
		else cout << N2C(v[i].first, v[i].second);
	}
	cout << endl;
	
	v.clear();
	//debug
	/*
	for(int i=0; i<(int)v.size(); i++){
		cout << v[i].first << " " << v[i].second << endl;
	}
	*/
	
}//end	
	
	return 0;
}