Give Me an E

Time limit1sMemory limit128 MB

Problem

Everyone knows that “E” is the most common letter in English. When you spell integers out in words, it is interesting to see which ones do NOT use the letter “E”. For example, 6030 (six thousand thirty) uses no “E”, and neither does 4002064 (four million two thousand sixty-four).

It turns out that 6030 is the 64th positive integer whose spelling avoids “E”, and 4002064 is the 838th such number. Your job is to find the $n$-th such number.

Note on spelling large numbers: 1,001,001,001,001,001,001,001,001,000 is spelled “one octillion, one septillion, one sextillion, one quintillion, one quadrillion, one trillion, one billion, one million, one thousand”.

Input

The input consists of several test cases. Each test case is a single positive integer $n$ ($n < 2^{31}$) on its own line. A line containing $0$ marks the end of the input. (The input contains no commas.)

Output

For each $n$, print the $n$-th positive integer whose spelling does not use the letter “E”, written with commas as thousands separators. You may assume every answer is less than $10^{28}$.