AMR11E - Distinct Primes

Arithmancy is Draco Malfoy's favorite subject, but what spoils it for him is that Hermione Granger is in his class, and she is better than him at it. Prime numbers are of mystical importance in Arithmancy, and Lucky Numbers even more so. Lucky Numbers are those positive integers that have at least three distinct prime factors; 30 and 42 are the first two. Malfoy's teacher has given them a positive integer n, and has asked them to find the n-th lucky number. Malfoy would like to beat Hermione at this exercise, so although he is an evil git, please help him, just this once. After all, the know-it-all Hermione does need a lesson.

Input

The first line contains the number of test cases T. Each of the next T lines contains one integer n.

Output

Output T lines, containing the corresponding lucky number for that test case.

Constraints

1 <= T <= 20
1 <= n <= 1000

Example

Sample Input:
2
1
2

Sample Output:
30
42

Added by:Varun Jalan
Date:2011-12-15
Time limit:3s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Varun Jalan - ICPC Asia regionals, Amritapuri 2011

hide comments
2015-01-22 17:33:24 fanatique
solved with the help of comments.. :(
2014-12-29 19:23:17 swordfish12
brute---wait for it---force...
2014-11-01 13:47:56 Pratik Kumar
i don't wish to help him, evil git
2014-02-08 15:16:16 Mukund Kumar
my 100th problem :)
2013-11-21 20:54:35 Chandan Mittal
piece of cake :)
2013-07-18 09:37:07 KARTIK KESHRI
got AC in 1st attempt in 0.00s
2013-07-16 16:56:08 BLANKRK
nthng spacl... :P
2013-07-15 18:41:30 Vipul Pandey
easy one. got ac in 0.00s. there is no need to sort.
2013-06-03 15:08:12 Nishant Gupta
brings up my half century \m/
2013-05-05 10:07:38 Ouditchya Sinha
AC in 0.00s :P :)
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.