### A-Number and B-Number

Time Limit: 1000 ms Memory Limit: 65536 KiB

#### Problem Description

Tom is very interested in number problem. Nowadays he is thinking of a problem about A-number and B-number.
A-number is a positive integer whose decimal form contains 7 or it can be divided by 7. We can write down the first 10 A-number ( a[i] is the ith A-number)
{a=7,a=14,a=17,a=21,a=27,a=28,a=35,a=37,a=42,a=47};
B-number is Sub-sequence of A-number which contains all A-number but a[k] ( that k is a  A-number.)  Like 35, is the 7th A-number and 7 is also an A-number so the 35 ( a ) is not a B-number. We also can write down the first 10 B-number.

{b=7,b=14,b=17,b=21,b=27,b=28,b=37,b=42,b=47,b=49};
Now Given an integer N, please output the Nth B-number

#### Input

The input consists of multiple test cases.

For each test case, there will be a positive integer N as the description.

#### Output

For each test case, output an integer indicating the Nth B-number.

You can assume the result will be no more then 2^63-1.

#### Sample Input

1
7
100

#### Sample Output

7
37
470

#### Source

2013年山东省第四届ACM大学生程序设计竞赛