Aronson#1809

Aronson

1 second
64 megabytes
Very easy

Aronson's sequence a_k 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 \textbf{1}, \textbf{4}, \textbf{11}, \textbf{16}, \textbf{24}, \textbf{29}, \textbf{33}, \textbf{35}, \textbf{39}, .... Note that non-letter characters and spaces are not considered in the formulation of the sequence. When \textbf{k} \leq \textbf{100000}, it turns out that \textbf{a_k} \leq \textbf{1000000}.

To formulate the sequence, you must be able to write the ordinal numbers in English. The ordinal numbers are \textit{\textbf{first}}, \textit{\textbf{second}}, \textit{\textbf{third}}, ..., while the cardinal numbers are \textit{\textbf{one}}, \textit{\textbf{two}}, \textit{\textbf{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 a table (\textbf{3} \to \textit{\textbf{three}}, \textbf{17} \to \textit{\textbf{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 (\textbf{40} \to \textit{\textbf{forty}}, \textbf{56} \to \textit{\textbf{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 (\textbf{100} \to \textit{\textbf{one hundred}}, \textbf{117} \to \textit{\textbf{one hundred seventeen}}, \textbf{640} \to \textit{\textbf{six hundred forty}}, \textbf{999} \to \textit{\textbf{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 (\textbf{12345} \to \textit{\textbf{twelve thousand three hundred forty five}}). An ordinal number is written as a cardinal number, but with the last word ordinalized using the third and fourth columns of a table.

Some example ordinal numbers: \textbf{3rd} \to \textit{\textbf{third}}, \textbf{56th} \to \textit{\textbf{fifty sixth}}, \textbf{100th} \to \textit{\textbf{one hundredth}}, and \textbf{12345th} \to \textit{\textbf{twelve thousand three hundred forty fifth}}.

Input

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

Output

For each , print the value of a_k on one line. The values of \textbf{a_k} will be at most .

Examples

Example 1

Loading
Loading