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 <cstring>
#include <cstdlib>
#include <cstdio>
using namespace std;

#define MAXLEN 1024

char *renovate(char *s);
char judge(char string, int c){

  if(string == '1'){
    if(c % 5 == 1){
      return '.';
    } else if(c % 5 == 2){
      return ',';
    } else if(c % 5 == 3){
      return '!';
    } else if(c % 5 == 4){
      return '?';
    } else if(c % 5 == 0){
      return ' ';
    }

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

}
  
int main(void){
  char str[MAXLEN + 1];

  fgets(str, MAXLEN, stdin);

  if(str[strlen(str) - 1] == '\n'){
    str[strlen(str) - 1] = '\0';
  }

  cout << renovate(str) << endl;

  return 0;
}

char *renovate(char *s){
  char *answer = (char *)malloc(sizeof(s)), number = ' ';
  int i, j = 0, count = 0;

  if(s[strlen(s) - 1] != '0'){
    answer[0] = 'a';
    return answer;
  }

  for(i = 0; *(s + i) != '\0'; i++){
    if(*(s + i) != '0'){
      if(count == 0){
	number = *(s + i);
	count++;
      } else if(count != 0){
	count++;
      } 
    } else if(*(s + i) == '0'){
      if(number != ' '){
	answer[j++] = judge(number, count);
	count = 0;
	number = ' ';
      }
    }
  }

  answer[j] = '\0';

  return answer;
}

C++: // 2006_KeitaiMessage.cpp
//
#include <bits/stdc++.h>
using namespace std;
int n;
string m;
char d[10][5] = {
  {},
  {'.', ',', '!', '?', ' '},
  {'a', 'b', 'c'},
  {'d', 'e', 'f'},
  {'g', 'h', 'i'},
  {'j', 'k', 'l'},
  {'m', 'n', 'o'},
  {'p', 'q', 'r', 's'},
  {'t', 'u', 'v'},
  {'w', 'x', 'y', 'z'},
};
int len[10] = {-1, 5, 3, 3, 3, 3, 3, 4, 3, 4};

vector<string> split(string &str, char sep) {
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while(getline(ss, buffer, sep)) {
    if(buffer != "") v.push_back(buffer);
  }
  return v;
}

void solve() {
  vector<string> v1 = split(m, '0');
  for_each(v1.begin(), v1.end(), [](string& x) {
      int a = x[0] - '0';
      int b = (x.length() <= len[a] ? x.length() - 1 : x.length()%len[a] - 1);
      cout << d[a][b];
    });
  cout << endl;
}

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> m;
    solve();
  }
  return 0;
}

C++: ///
// File:  2006.cpp
// Author: ymiyamoto
//
// Created on Fri Nov 10 06:23:37 2017
//

#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

static vector<string> arr({"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"});

int32_t main()
{
  uint32_t N;
  cin >> N;

  for (uint32_t i = 0; i < N; i++) {
    string str;
    cin >> str;
    uint32_t pre = 0;
    int32_t num = -1;
    for (uint32_t j = 0; j < str.size(); j++) {
      int32_t but = str[j] - '0';
      if (but == 0) {
        if (pre != 0) {
          cout << arr[pre][num];
        }
        pre = 0;
        num = -1;
      } else {
        pre = but;
        num++;
        num = num % arr[but].size();
      }
    }
    cout << endl;
  }

  return 0;
}

C++: #include <bits/stdc++.h>
#define NIL -1

int N;

int main()
{
    char com[][5] = {
        {},
        {'.', ',', '!', '?', ' '},
        {'a', 'b', 'c'},
        {'d', 'e', 'f'},
        {'g', 'h', 'i'},
        {'j', 'k', 'l'},
        {'m', 'n', 'o'},
        {'p', 'q', 'r', 's'},
        {'t', 'u', 'v'},
        {'w', 'x', 'y', 'z'}
    };
    int lens[] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4};
    std::cin >> N;
    std::string msg;


    for (int t = 0; t < N; t++) {
        std::cin >> msg;
        std::string res;
        int cnt = NIL;
        char btn = '#';

        bool isPressed0 = false;

        //find first index where character is not 0
        unsigned long start = 0;
        for (unsigned long i = 0; i < msg.size(); i++) {
            if (msg[i] != '0') {
                start = i + 1;
                btn = msg[i];
                cnt = 0;
                break;
            }
        }

        for (unsigned long i = start; i < msg.size(); i++) {
            //if 0 is already pushed
            if (msg[i] == '0' && isPressed0) { continue; }

            else if (msg[i] == '0' && !isPressed0) {
                int idx = (int) btn - '0';
                res += com[idx][cnt % lens[idx]];
                isPressed0 = true;
            }

            else if (msg[i] != '0' && isPressed0) {
                cnt = 0;
                btn = msg[i];
                isPressed0 = false;
            }

            else {
                cnt++;
            }
        }

        std::cout << res << std::endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
#define rep(i,j) for(int i = 0; i < (j); i++)
int main(){
	int n;
	cin >> n;
	string c[] = {"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};	
	while(n--){
		string str;
		cin >> str;
		string ans = "";
		rep(i,str.size()){
			if(str[i] == '0')continue;
			int sub = i;
			while(str[i] == str[++sub]);
			ans += c[str[sub-1]-48][(sub-i-1)%c[str[sub-1]-48].size()];
			i = sub;
		}
		cout << ans << endl;
	}	
	return 0;
}