package com.thinker.bishi.huawei;

import java.util.Scanner;

/**
 * @author lzh
 * @apiNote one two three four five six seven eight nine zero double ol
 *          还有一个表示零的忘记是什么了，只记得好像是以o开头的好像还是两位，就暂时用
 *          ol代替吧，原理一样的。*_*
 */
public class Convert {

    private static StringBuilder pri = new StringBuilder();
    private static boolean isError = false;
    /**
     * @apiNote 检查字符串中有没有数字。
     * @param str str
     * @return boolean
     */
    private static boolean check(String str){
        boolean result = true;
        char[] tmp = str.toCharArray();
        for(int i=0;i<tmp.length;i++){
            result = ((int)tmp[i] >= 65 && (int)tmp[i] <= 90) ||
                   ((int)tmp[i] >= 97 && (int)tmp[i] <= 122);
        }
        return result;
    }

    /**
     * @apiNote 利用递归判断当前字母表示的数字
     * @param str char[]
     * @param curr 当前位置
     * @param flag 前一个是否为double
     */
    private static void result(char[] str,int curr,boolean flag){
        if(!(curr<str.length))return;
        boolean currFlag = false;
        int currNum = 0;
        if(str[curr] == 'f' || str[curr] == 'F'){
            if(str[curr + 1] == 'i' || str[curr + 1] == 'I'){ curr += 4;currNum = 5;}
            else if(str[curr + 1] == 'o' || str[curr + 1] == 'O'){ curr += 4;currNum = 4;}
        }else if(str[curr] == 't' || str[curr] == 'T'){
            if(str[curr + 1] == 'w' || str[curr + 1] == 'W'){ curr += 3;currNum = 2;}
            else if(str[curr + 1] == 'h' || str[curr + 1] == 'H'){ curr += 5;currNum = 3;}
        }else if(str[curr] == 's' || str[curr] == 'S'){
            if(str[curr + 1] == 'i' || str[curr + 1] == 'I'){ curr += 3;currNum = 6;}
            else if(str[curr + 1] == 'e' || str[curr + 1] == 'E'){ curr += 5;currNum = 7;}
        }else if(str[curr] == 'o' || str[curr] == 'O'){
            if(str[curr + 1] == 'n' || str[curr + 1] == 'N'){ curr += 3;currNum = 1;}
            else if(str[curr + 1] == 'l' || str[curr + 1] == 'L'){ curr += 2;currNum = 0;}
        }else if(str[curr] == 'e' || str[curr] == 'E'){
            curr += 5;currNum = 8;
        }else if(str[curr] == 'n' || str[curr] == 'N'){
            curr += 4; currNum = 9;
        }else if(str[curr] == 'd' || str[curr] == 'D') {
            curr += 6; currFlag = true;
        }else {
            isError = true;
            return;
        }
        if(flag && currFlag) {
            isError = true;
            return;
        }
        if(flag) pri.append(currNum).append(currNum);
        else pri.append(currNum);
        result(str, curr, currFlag);
    }

    /**
     *
     * @param str 输入的字符串
     */
    private static void result(String str){
        if(!check(str)) {
            System.out.println("error");
            return;
        }
        result(str.toCharArray(),0,false);
        if(!isError)System.out.println(pri.toString());
        else System.out.println("error");
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int len = Integer.parseInt(in.nextLine());
        for(int i=0;i<len;i++){
            String str = in.nextLine();
            result(str);
        }
    }
}
