Problem I: Aronson


Source: aronson.{c,cpp,java}
Input: console {stdin,cin,System.in}
Output: console {stdout,cout,System.out}

Aronson's sequence ak is a sequence of integers defined by the sentence "t is the first, fourth, eleventh, ... letter of this sentence.", where the ... are filled in appropriately so that the sentence makes sense. The first few values are 1, 4, 11, 16, 24, 29, 33, 35, 39, .... Note the non-letter characters and spaces are not considered in the formulation of the sequence. When k ≤ 100000, it turns out that ak ≤ 1000000.

To formulate the sequence, you must be able to write the ordinal numbers in English. The ordinal numbers are first, second, third, ..., while the cardinal numbers are one, two, three, .... It is easiest to define the ordinals in terms of the cardinals, so we describe these first.

A cardinal number less than twenty is written directly from the first two columns of table 1 (3→three, 17→seventeen, etc.). A cardinal number greater than or equal to twenty, but less than one hundred is written as the tens part, along with a nonzero ones part (40→ forty, 56→fifty six, etc). A cardinal number greater than or equal to one hundred, but less than one thousand, is written as the hundreds part, along with a nonzero remainder (100→one hundred, 117→one hundred seventeen, 640→six hundred forty, 999→nine hundred ninety nine). A cardinal number greater than or equal to one thousand, but less than one million, is written as the thousands part, along with a nonzero remainder (12345→twelve thousand three hundred forty five). An ordinal number is written as a cardinal number, but with the last word ordinalized using the columns three and four of table 1.

Some example ordinal numbers are 3rd→third, 56th→fifty sixth, 100th→one hundredth, and 12345th→twelve thousand three hundred forty fifth.

Input

The input consists of a number of cases. Each case is specified by a positive integer k on one line (1 ≤ k ≤ 100000). The sequence of k values will be non-decreasing. The input is terminated by a line containing a single 0.

Output

For each k, print the value of ak on one line. The values of ak will be at most 1000000.

Sample input

1
3
9
0

Sample Output

1
11
39
ncardinalnthordinal
1one1stfirst
2two2ndsecond
3three3rdthird
4four4thfourth
5five5thfifth
6six6thsixth
7seven7thseventh
8eight8theighth
9nine9thninth
10ten10thtenth
11eleven11theleventh
12twelve12thtwelfth
13thirteen13ththirteenth
14fourteen14thfourteenth
15fifteen15thfifteenth
16sixteen16thsixteenth
17seventeen17thseventeenth
18eighteen18theighteenth
19nineteen19thnineteenth
20twenty20thtwentieth
30thirty30ththirtieth
40forty40thfortieth
50fifty50thfiftieth
60sixty60thsixtieth
70seventy70thseventieth
80eighty80theightieth
90ninety90thninetieth
100hundred100thhundredth
1000thousand1000ththousandth

Table 1: Translation table.