Time Limit: 2 Seconds
Memory Limit: 65536 KB
17171771 is a sweet song in Jaurim's 5th album, "All You Need Is Love", released in October 2004.
What's the meaning of 17171771? If we rotate it by 180 degrees, it looks like "ILLILILI". If we add some blanks into it, it becomes "I LLILI LI". Doesn't it look like "I LUV U"? The meaning of 17171771 is "I LUV U". Anyway, it has nothing to do with our problem.
What we are concerned more about is that, 17171771 is a prime consisting only of digits 1 and 7 occurring with equal frequency. In this problem, a prime consisting only of two different digits occurring with equal frequency is called nice number. For example, 89, 71717117 and 23323333222223 are nice numbers.
Your task is to print all the nice numbers which are strictly less than 1018
Output all the nice number less than 1018 in increasing order. The output looks like the following:
13 17 19 ... 17171771 ...