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 nth 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 (STDIN):
The first line contains the number of test cases T. Each of the next T lines contains one integer n.
Output (STDOUT):
Output T lines, containing the corresponding lucky number for that test case.
Constraints:
1 <= T <= 20
1 <= n <= 1000
Sample Input:
2
1
2
1 540, 2 546, 3 550, 4 552, 5 555, 6 558, 7 560, 8 561, 9 564, 10 570, 11 572, 12 574, 13 580, 14 582, 15 585, 16 588, 17 590, 18 594, 19 595, 20 598, 21 600, 22 602, 23 606, 24 609, 25 610, 26 612, 27 615, 28 616, 29 618, 30 620, 31 624, 32 627, 33 630, 34 636, 35 638, 36 642, 37 644, 38 645, 39 646, 40 650, 41 651, 42 654, 43 658, 44 660, 45 663, 46 665, 47 666, 48 670, 49 672, 50 678, 51 680, 52 682, 53 684, 54 690, 55 693, 56 696, 57 700, 58 702, 59 705, 60 708, 61 710, 62 714, 63 715, 64 720, 65 726, 66 728, 67 730, 68 732, 69 735, 70 738, 71 740, 72 741, 73 742, 74 744, 75 748, 76 750, 77 754, 78 756, 79 759, 80 760, 81 762, 82 765, 83 770, 84 774, 85 777, 86 780, 87 782, 88 786, 89 790, 90 792, 91 795, 92 798, 93 804, 94 805, 95 806, 96 810, 97 812, 98 814, 99 816, 100 819, 101 820, 102 822, 103 825, 104 826, 105 828, 106 830, 107 834, 108 836, 109 840, 110 846, 111 850, 112 852, 113 854, 114 855, 115 858, 116 860, 117 861, 118 868, 119 870, 120 874, 121 876, 122 880, 123 882, 124 884, 125 885, 126 888, 127 890, 128 894, 129 897, 130 900, 131 902, 132 903, 133 906, 134 910, 135 912, 136 915, 137 918, 138 920, 139 924, 140 930, 141 935, 142 936, 143 938, 144 940, 145 942, 146 945, 147 946, 148 948, 149 950, 150 952, 151 954, 152 957, 153 960, 154 962, 155 966, 156 969, 157 970, 158 975, 159 978, 160 980, 161 984, 162 986, 163 987, 164 988, 165 990, 166 994, 167 996, 168 1001, 169 1002, 170 1005, 171 1008, 172 1010, 173 1012, 174 1014, 175 1015, 176 1020, 177 1022, 178 1023, 179 1026, 180 1030, 181 1032, 182 1034, 183 1035, 184 1036, 185 1038, 186 1040, 187 1044, 188 1045, 189 1050, 190 1054, 191 1056, 192 1060, 193 1062, 194 1064, 195 1065, 196 1066, 197 1068, 198 1070, 199 1071, 200 1074, 201 1078, 202 1080, 203 1085, 204 1086, 205 1090, 206 1092, 207 1095, 208 1098, 209 1100, 210 1102, 211 1104, 212 1105, 213 1106, 214 1110, 215 1113, 216 1116, 217 1118, 218 1120, 219 1122, 220 1128, 221 1130, 222 1131, 223 1134, 224 1140, 225 1144, 226 1146, 227 1148, 228 1150, 229 1155, 230 1158, 231 1160, 232 1162, 233 1164, 234 1166, 235 1170, 236 1173, 237 1176, 238 1178, 239 1180, 240 1182, 241 1185, 242 1188, 243 1190, 244 1194, 245 1196, 246 1197, 247 1200, 248 1204, 249 1206, 250 1209, 251 1210, 252 1212, 253 1218, 254 1220, 255 1221, 256 1222, 257 1224, 258 1230, 259 1232, 260 1235, 261 1236, 262 1239, 263 1240, 264 1242, 265 1245, 266 1246, 267 1248, 268 1254, 269 1258, 270 1260, 271 1265, 272 1266, 273 1270, 274 1272, 275 1274, 276 1275, 277 1276, 278 1278, 279 1281, 280 1284, 281 1287, 282 1288, 283 1290, 284 1292, 285 1295, 286 1298, 287 1300, 288 1302, 289 1305, 290 1308, 291 1309, 292 1310, 293 1311, 294 1314, 295 1316, 296 1320, 297 1326, 298 1330, 299 1332, 300 1334, 301 1335, 302 1338, 303 1340, 304 1342, 305 1344, 306 1350, 307 1353, 308 1356, 309 1358, 310 1360, 311 1362, 312 1364, 313 1365, 314 1368, 315 1370, 316 1374, 317 1378, 318 1380, 319 1386, 320 1390, 321 1392, 322 1394, 323 1395, 324 1398, 325 1400, 326 1404, 327 1406, 328 1407, 329 1410, 330 1414, 331 1416, 332 1419, 333 1420, 334 1422, 335 1425, 336 1426, 337 1428, 338 1430, 339 1434, 340 1435, 341 1440, 342 1442, 343 1443, 344 1446, 345 1449, 346 1450, 347 1452, 348 1455, 349 1456, 350 1460, 351 1462, 352 1463, 353 1464, 354 1470, 355 1474, 356 1476, 357 1479, 358 1480, 359 1482, 360 1484, 361 1485, 362 1488, 363 1490, 364 1491, 365 1494, 366 1495, 367 1496, 368 1498, 369 1500, 370 1505, 371 1506, 372 1508, 373 1510, 374 1512, 375 1515, 376 1518, 377 1520, 378 1524, 379 1526, 380 1530, 381 1533, 382 1534, 383 1540, 384 1542, 385 1545, 386 1547, 387 1548, 388 1550, 389 1551, 390 1554, 391 1558, 392 1560, 393 1562, 394 1564, 395 1566, 396 1570, 397 1572, 398 1575, 399 1578, 400 1580, 401 1581, 402 1582, 403 1584, 404 1586, 405 1590, 406 1595, 407 1596, 408 1598, 409 1599, 410 1602, 411 1605, 412 1606, 413 1608, 414 1610, 415 1612, 416 1614, 417 1615, 418 1617, 419 1620, 420 1624, 421 1626, 422 1628, 423 1630, 424 1632, 425 1634, 426 1635, 427 1638, 428 1640, 429 1644, 430 1645, 431 1650, 432 1652, 433 1653, 434 1656, 435 1659, 436 1660, 437 1662, 438 1665, 439 1666, 440 1668, 441 1670, 442 1672, 443 1674, 444 1677, 445 1680, 446 1683, 447 1686, 448 1690, 449 1692, 450 1694, 451 1695, 452 1698, 453 1700, 454 1702, 455 1704, 456 1705, 457 1708, 458 1710, 459 1716, 460 1720, 461 1722, 462 1725, 463 1729, 464 1730, 465 1734, 466 1736, 467 1738, 468 1740, 469 1742, 470 1743, 471 1746, 472 1748, 473 1749, 474 1750, 475 1752, 476 1755, 477 1758, 478 1760, 479 1764, 480 1767, 481 1768, 482 1770, 483 1771, 484 1776, 485 1778, 486 1780, 487 1782, 488 1785, 489 1786, 490 1788, 491 1790, 492 1794, 493 1798, 494 1800, 495 1802, 496 1804, 497 1806, 498 1810, 499 1812, 500 1815, 501 1818, 502 1820, 503 1824, 504 1826, 505 1827, 506 1830, 507 1833, 508 1834, 509 1836, 510 1840, 511 1842, 512 1845, 513 1846, 514 1848, 515 1850, 516 1854, 517 1855, 518 1860, 519 1862, 520 1866, 521 1869, 522 1870, 523 1872, 524 1876, 525 1878, 526 1880, 527 1881, 528 1884, 529 1885, 530 1886, 531 1887, 532 1890, 533 1892, 534 1896, 535 1898, 536 1900, 537 1902, 538 1904, 539 1905, 540 1908, 541 1910, 542 1911, 543 1914, 544 1918, 545 1920, 546 1924, 547 1925, 548 1926, 549 1930, 550 1932, 551 1935, 552 1938, 553 1940, 554 1946, 555 1947, 556 1950, 557 1953, 558 1955, 559 1956, 560 1958, 561 1960, 562 1962, 563 1965, 564 1968, 565 1970, 566 1972, 567 1974, 568 1976, 569 1978, 570 1980, 571 1986, 572 1988, 573 1989, 574 1990, 575 1992, 576 1995, 577 1998, 578 2001, 579 2002, 580 2004, 581 2006, 582 2010, 583 2013, 584 2014, 585 2015, 586 2016, 587 2020, 588 2022, 589 2024, 590 2028, 591 2030, 592 2034, 593 2035, 594 2037, 595 2040, 596 2044, 597 2046, 598 2050, 599 2052, 600 2054, 601 2055, 602 2058, 603 2060, 604 2064, 605 2065, 606 2067, 607 2068, 608 2070, 609 2072, 610 2074, 611 2076, 612 2079, 613 2080, 614 2082, 615 2085, 616 2086, 617 2088, 618 2090, 619 2091, 620 2093, 621 2094, 622 2100, 623 2106, 624 2108, 625 2109, 626 2110, 627 2112, 628 2114, 629 2115, 630 2118, 631 2120, 632 2121, 633 2124, 634 2128, 635 2130, 636 2132, 637 2134, 638 2135, 639 2136, 640 2139, 641 2140, 642 2142, 643 2145, 644 2146, 645 2148, 646 2150, 647 2154, 648 2156, 649 2158, 650 2160, 651 2162, 652 2163, 653 2166, 654 2170, 655 2172, 656 2175, 657 2178, 658 2180, 659 2184, 660 2185, 661 2190, 662 2193, 663 2196, 664 2198, 665 2200, 666 2202, 667 2204, 668 2205, 669 2208, 670 2210, 671 2211, 672 2212, 673 2214, 674 2220, 675 2222, 676 2223, 677 2226, 678 2230, 679 2232, 680 2233, 681 2235, 682 2236, 683 2238, 684 2240, 685 2242, 686 2244, 687 2247, 688 2250, 689 2254, 690 2255, 691 2256, 692 2260, 693 2261, 694 2262, 695 2265, 696 2266, 697 2268, 698 2270, 699 2274, 700 2275, 701 2277, 702 2278, 703 2280, 704 2282, 705 2286, 706 2288, 707 2289, 708 2290, 709 2292, 710 2294, 711 2295, 712 2296, 713 2298, 714 2300, 715 2301, 716 2310, 717 2314, 718 2316, 719 2318, 720 2320, 721 2322, 722 2324, 723 2325, 724 2328, 725 2330, 726 2331, 727 2332, 728 2334, 729 2337, 730 2338, 731 2340, 732 2343, 733 2345, 734 2346, 735 2350, 736 2352, 737 2354, 738 2355, 739 2356, 740 2358, 741 2360, 742 2364, 743 2365, 744 2366, 745 2370, 746 2373, 747 2376, 748 2378, 749 2379, 750 2380, 751 2382, 752 2385, 753 2387, 754 2388, 755 2390, 756 2392, 757 2394, 758 2397, 759 2398, 760 2400, 761 2405, 762 2406, 763 2408, 764 2409, 765 2410, 766 2412, 767 2414, 768 2415, 769 2418, 770 2420, 771 2422, 772 2424, 773 2430, 774 2431, 775 2436, 776 2438, 777 2440, 778 2442, 779 2444, 780 2445, 781 2448, 782 2450, 783 2451, 784 2454, 785 2457, 786 2460, 787 2464, 788 2465, 789 2466, 790 2470, 791 2472, 792 2475, 793 2478, 794 2480, 795 2482, 796 2484, 797 2485, 798 2486, 799 2490, 800 2492, 801 2494, 802 2496, 803 2499, 804 2502, 805 2505, 806 2506, 807 2508, 808 2510, 809 2514, 810 2516, 811 2520, 812 2522, 813 2526, 814 2530, 815 2532, 816 2534, 817 2535, 818 2538, 819 2540, 820 2541, 821 2542, 822 2544, 823 2546, 824 2548, 825 2550, 826 2552, 827 2553, 828 2555, 829 2556, 830 2562, 831 2565, 832 2568, 833 2570, 834 2574, 835 2576, 836 2580, 837 2583, 838 2584, 839 2585, 840 2586, 841 2590, 842 2595, 843 2596, 844 2598, 845 2600, 846 2604, 847 2607, 848 2610, 849 2613, 850 2616, 851 2618, 852 2620, 853 2622, 854 2625, 855 2626, 856 2628, 857 2630, 858 2632, 859 2634, 860 2635, 861 2639, 862 2640, 863 2646, 864 2650, 865 2652, 866 2655, 867 2658, 868 2660, 869 2664, 870 2665, 871 2666, 872 2667, 873 2668, 874 2670, 875 2674, 876 2676, 877 2678, 878 2679}; 879 /*int main() 880 { 881 882 int o=1,flag; 883 for(int m=1;m<100000;m++) 884 { 885 if( 886 ((m%2==0)&&(m%3==0)&&(m%5==0))|| 887 ((m%2==0)&&(m%3==0)&&(m%7==0))|| 888 ((m%2==0)&&(m%3==0)&&(m%11==0))|| 889 ((m%2==0)&&(m%3==0)&&(m%13==0))|| 890 ((m%2==0)&&(m%3==0)&&(m%17==0))|| 891 ((m%2==0)&&(m%3==0)&&(m%19==0))|| 892 ((m%2==0)&&(m%7==0)&&(m%5==0))|| 893 ((m%2==0)&&(m%11==0)&&(m%5==0))|| 894 ((m%2==0)&&(m%13==0)&&(m%5==0))|| 895 ((m%2==0)&&(m%17==0)&&(m%5==0))|| 896 ((m%2==0)&&(m%19==0)&&(m%5==0))|| 897 ((m%2==0)&&(m%7==0)&&(m%11==0))|| 898 ((m%2==0)&&(m%7==0)&&(m%13==0))|| 899 ((m%2==0)&&(m%7==0)&&(m%17==0))|| 900 ((m%2==0)&&(m%7==0)&&(m%19==0))|| 901 ((m%2==0)&&(m%11==0)&&(m%13==0))|| 902 ((m%2==0)&&(m%11==0)&&(m%17==0))|| 903 ((m%2==0)&&(m%11==0)&&(m%19==0))|| 904 ((m%2==0)&&(m%13==0)&&(m%17==0))|| 905 ((m%2==0)&&(m%17==0)&&(m%19==0))|| 906 ((m%3==0)&&(m%7==0)&&(m%5==0))|| 907 ((m%11==0)&&(m%3==0)&&(m%5==0))|| 908 ((m%13==0)&&(m%3==0)&&(m%5==0))|| 909 ((m%17==0)&&(m%3==0)&&(m%5==0))|| 910 ((m%19==0)&&(m%3==0)&&(m%5==0))|| 911 ((m%7==0)&&(m%3==0)&&(m%11==0))|| 912 ((m%7==0)&&(m%3==0)&&(m%13==0))|| 913 ((m%7==0)&&(m%3==0)&&(m%17==0))|| 914 ((m%7==0)&&(m%3==0)&&(m%19==0))|| 915 ((m%11==0)&&(m%3==0)&&(m%13==0))|| 916 ((m%11==0)&&(m%3==0)&&(m%17==0))|| 917 ((m%11==0)&&(m%3==0)&&(m%19==0))|| 918 ((m%13==0)&&(m%3==0)&&(m%17==0))|| 919 ((m%13==0)&&(m%3==0)&&(m%19==0))|| 920 ((m%17==0)&&(m%3==0)&&(m%19==0))|| 921 ((m%11==0)&&(m%7==0)&&(m%5==0))|| 922 ((m%13==0)&&(m%7==0)&&(m%5==0))|| 923 ((m%17==0)&&(m%7==0)&&(m%5==0))|| 924 ((m%19==0)&&(m%7==0)&&(m%5==0))|| 925 ((m%17==0)&&(m%11==0)&&(m%5==0))|| 926 ((m%19==0)&&(m%11==0)&&(m%5==0))|| 927 ((m%13==0)&&(m%11==0)&&(m%5==0))|| 928 ((m%13==0)&&(m%11==0)&&(m%7==0))|| 929 ((m%17==0)&&(m%11==0)&&(m%7==0))|| 930 ((m%19==0)&&(m%11==0)&&(m%7==0))|| 931 ((m%17==0)&&(m%13==0)&&(m%11==0))|| 932 ((m%19==0)&&(m%13==0)&&(m%11==0))|| 933 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 934 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 935 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 936 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 937 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 938 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 939 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 940 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 941 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 942 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 943 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 944 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 945 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 946 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 947 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 948 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 949 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 950 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 951 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 952 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 953 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 954 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 955 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 956 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 957 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 958 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 959 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 960 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 961 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 962 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 963 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 964 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 965 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 966 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 967 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 968 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 969 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 970 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 971 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 972 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 973 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 974 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 975 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 976 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 977 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 978 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 979 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 980 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 981 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 982 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 983 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 984 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 985 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 986 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 987 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 988 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 989 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 990 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 991 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 992 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 993 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 994 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 995 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 996 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 997 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 998 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 999 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1000 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1001 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1002 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1003 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1004 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1005 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1006 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1007 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1008 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1009 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1010 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1011 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1012 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1013 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1014 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1015 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1016 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1017 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1018 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1019 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1020 ((m%19==0)&&(m%17==0)&&(m%13==0))|| 1021 ((m%19==0)&&(m%17==0)&&(m%13==0)) 1022 1023 ) 1024 { 1025 flag=0; 1026 for(int q=m-1;q>0;q--) 1027 { 1028 if(a[q]==m) 1029 flag=1; 1030 } 1031 if(flag==0) 1032 { 1033 a[o]=m; 1034 o=o+1; 1035 } 1036 } 1037 } 1038 int n; 1039 scanf("%d",&n); 1040 FILE *fp;//建立一个文件操作指针 1041 fp=fopen("1.txt","w+");//以追加的方式建立或打开1.txt,默认位置在你程序的目录下面 1042 for(int i=0;i<n;i++) 1043 { 1044 1045 printf("%d ",a[i]); 1046 fprintf(fp,"%d, ",a[i]); 1047 } 1048 return 0; 1049 } */ 1050 int main() 1051 { 1052 int n; 1053 scanf("%d",&n); 1054 while(n--) 1055 { 1056 int m; 1057 scanf("%d",&m); 1058 printf("%d ",a[m]); 1059 } 1060 return 0; 1061 }