using namespace std;

string num[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
string suf[] = {"shi", "bai", "qian", "wan", "yi"};
vector<string> v;

string n2s(const string& n) {
    int l = n.length();
    if (l == 1) {
        return num[n[0]-'0'];
    } else if (n[0] == '0' && n[1] == '0') {
        return num[n[0]-'0'] + n2s(n.substr(2, l-2));
    } else {
        return num[n[0]-'0'] + (n[0] == '0' ? "" : suf[l-2])
            + n2s(n.substr(1, l-1));
    }
}

string ln2s(const string& n) {
    int l = n.length();
    if (l < 5) {
        return n2s(n);
    } else if (l < 9) {
        return n2s(n.substr(0, l-4)) + "wan" + n2s(n.substr(l-4, 4));
    } else {
        return n2s(n.substr(0, l-8)) + "yi" + ln2s(n.substr(l-8, 8));
    }
}

int test() {
    cout << n2s("1001") << endl;
    cout << n2s("1010") << endl;
    cout << n2s("1101") << endl;
    cout << ln2s("11101") << endl;
    cout << ln2s("101101") << endl;
    cout << ln2s("1101") << endl;
    return 0;
}