#!/usr/bin/ruby
require 'prime'
M=28123
a=[];h={}
#1.step(M){|i|x=i.prime_division.reduce(1){|s,e|s*(e[0]**(e[1]+1)-1)/(e[0]-1)}-i;a<<i if i<x}
#a.size.times{|i|a.size.times{|j|h[a[i]+a[j]]=1 if a[i]+a[j]<=M}}
#p 1.step(M).select{|i|!h[i]}.reduce(:+)

z=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 31, 33, 34, 35, 37, 39, 41, 43, 45, 46, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, 261, 263, 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 285, 287, 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, 319, 321, 323, 325, 327, 329, 331, 333, 335, 337, 339, 341, 343, 345, 347, 349, 351, 353, 355, 357, 359, 361, 363, 365, 367, 369, 371, 373, 375, 377, 379, 381, 383, 385, 387, 389, 391, 393, 395, 397, 399, 401, 403, 405, 407, 409, 411, 413, 415, 417, 419, 421, 423, 425, 427, 429, 431, 433, 435, 437, 439, 441, 443, 445, 447, 449, 451, 453, 455, 457, 459, 461, 463, 465, 467, 469, 471, 473, 475, 477, 479, 481, 483, 485, 487, 489, 491, 493, 495, 497, 499, 501, 503, 505, 507, 509, 511, 513, 515, 517, 519, 521, 523, 525, 527, 529, 531, 533, 535, 537, 539, 541, 543, 545, 547, 549, 551, 553, 555, 557, 559, 561, 563, 565, 567, 569, 571, 573, 575, 577, 579, 581, 583, 585, 587, 589, 591, 593, 595, 597, 599, 601, 603, 605, 607, 609, 611, 613, 615, 617, 619, 621, 623, 625, 627, 629, 631, 633, 635, 637, 639, 641, 643, 645, 647, 649, 651, 653, 655, 657, 659, 661, 663, 665, 667, 669, 671, 673, 675, 677, 679, 681, 683, 685, 687, 689, 691, 693, 695, 697, 699, 701, 703, 705, 707, 709, 711, 713, 715, 717, 719, 721, 723, 725, 727, 729, 731, 733, 735, 737, 739, 741, 743, 745, 747, 749, 751, 753, 755, 757, 759, 761, 763, 765, 767, 769, 771, 773, 775, 777, 779, 781, 783, 785, 787, 789, 791, 793, 795, 797, 799, 801, 803, 805, 807, 809, 811, 813, 815, 817, 819, 821, 823, 825, 827, 829, 831, 833, 835, 837, 839, 841, 843, 845, 847, 849, 851, 853, 855, 857, 859, 861, 863, 865, 867, 869, 871, 873, 875, 877, 879, 881, 883, 885, 887, 889, 891, 893, 895, 897, 899, 901, 903, 905, 907, 909, 911, 913, 915, 917, 919, 921, 923, 925, 927, 929, 931, 933, 935, 937, 939, 941, 943, 945, 947, 949, 951, 953, 955, 959, 961, 967, 971, 973, 977, 979, 983, 989, 991, 995, 997, 1003, 1007, 1009, 1013, 1019, 1021, 1027, 1031, 1037, 1039, 1043, 1051, 1055, 1061, 1063, 1067, 1069, 1073, 1075, 1079, 1081, 1087, 1091, 1093, 1097, 1099, 1103, 1109, 1111, 1115, 1117, 1123, 1127, 1129, 1133, 1135, 1139, 1147, 1151, 1157, 1159, 1163, 1171, 1175, 1177, 1181, 1183, 1187, 1189, 1193, 1195, 1199, 1201, 1207, 1211, 1213, 1219, 1223, 1229, 1231, 1235, 1237, 1241, 1243, 1247, 1255, 1259, 1261, 1267, 1271, 1273, 1277, 1279, 1283, 1289, 1291, 1301, 1303, 1307, 1315, 1319, 1321, 1327, 1331, 1333, 1339, 1343, 1349, 1351, 1355, 1357, 1363, 1367, 1369, 1373, 1375, 1379, 1381, 1387, 1391, 1397, 1399, 1403, 1411, 1415, 1417, 1423, 1427, 1429, 1433, 1439, 1441, 1447, 1451, 1453, 1457, 1459, 1463, 1469, 1471, 1475, 1481, 1483, 1487, 1493, 1499, 1501, 1507, 1511, 1513, 1519, 1523, 1529, 1531, 1535, 1537, 1541, 1543, 1547, 1549, 1555, 1559, 1567, 1571, 1573, 1577, 1579, 1583, 1591, 1597, 1601, 1603, 1607, 1609, 1613, 1619, 1621, 1627, 1633, 1637, 1639, 1643, 1651, 1657, 1661, 1667, 1669, 1691, 1697, 1699, 1703, 1709, 1711, 1717, 1721, 1723, 1727, 1733, 1739, 1741, 1747, 1753, 1759, 1763, 1769, 1787, 1789, 1793, 1801, 1807, 1811, 1817, 1819, 1823, 1829, 1831, 1837, 1843, 1849, 1853, 1859, 1861, 1867, 1871, 1877, 1889, 1891, 1901, 1903, 1907, 1909, 1919, 1921, 1931, 1933, 1949, 1951, 1957, 1961, 1963, 1969, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2021, 2027, 2029, 2041, 2047, 2053, 2057, 2059, 2063, 2069, 2071, 2077, 2081, 2083, 2087, 2099, 2101, 2111, 2113, 2117, 2123, 2131, 2137, 2141, 2143, 2153, 2159, 2167, 2171, 2173, 2179, 2189, 2197, 2201, 2203, 2207, 2209, 2213, 2221, 2227, 2231, 2237, 2239, 2243, 2249, 2251, 2263, 2267, 2269, 2273, 2281, 2287, 2291, 2299, 2327, 2329, 2333, 2339, 2341, 2347, 2351, 2357, 2363, 2369, 2371, 2377, 2383, 2389, 2393, 2399, 2419, 2423, 2431, 2437, 2447, 2453, 2459, 2461, 2467, 2473, 2479, 2483, 2489, 2491, 2497, 2501, 2507, 2519, 2521, 2531, 2533, 2537, 2539, 2549, 2551, 2561, 2563, 2579, 2581, 2587, 2591, 2593, 2599, 2603, 2623, 2627, 2629, 2633, 2647, 2651, 2657, 2659, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2701, 2707, 2711, 2717, 2729, 2731, 2741, 2743, 2747, 2753, 2761, 2767, 2771, 2773, 2783, 2789, 2797, 2803, 2809, 2819, 2827, 2831, 2837, 2839, 2843, 2851, 2857, 2861, 2867, 2869, 2873, 2879, 2893, 2899, 2903, 2911, 2917, 2957, 2959, 2963, 2971, 2977, 2981, 2987, 2993, 2999, 3001, 3007, 3013, 3019, 3023, 3029, 3049, 3053, 3061, 3067, 3077, 3083, 3089, 3091, 3097, 3103, 3109, 3113, 3119, 3127, 3131, 3137, 3149, 3151, 3161, 3163, 3167, 3169, 3179, 3181, 3191, 3193, 3209, 3211, 3217, 3221, 3223, 3229, 3253, 3257, 3259, 3263, 3277, 3281, 3287, 3289, 3301, 3307, 3317, 3319, 3323, 3329, 3331, 3341, 3347, 3359, 3361, 3371, 3373, 3383, 3391, 3397, 3401, 3403, 3413, 3419, 3427, 3433, 3439, 3449, 3457, 3461, 3467, 3469, 3473, 3481, 3487, 3491, 3499, 3503, 3509, 3523, 3533, 3541, 3547, 3587, 3589, 3593, 3601, 3607, 3611, 3617, 3623, 3629, 3631, 3637, 3643, 3653, 3659, 3679, 3683, 3691, 3707, 3713, 3719, 3721, 3727, 3733, 3739, 3743, 3749, 3757, 3767, 3779, 3781, 3791, 3793, 3797, 3799, 3809, 3811, 3821, 3823, 3839, 3841, 3847, 3851, 3853, 3859, 3883, 3887, 3893, 3907, 3911, 3917, 3919, 3931, 3947, 3949, 3959, 3971, 3977, 3989, 3991, 4001, 4003, 4013, 4021, 4027, 4031, 4033, 4043, 4049, 4057, 4063, 4069, 4079, 4087, 4091, 4097, 4099, 4103, 4111, 4117, 4121, 4129, 4133, 4139, 4153, 4163, 4171, 4177, 4217, 4219, 4223, 4231, 4237, 4241, 4247, 4253, 4259, 4261, 4267, 4283, 4309, 4313, 4321, 4343, 4349, 4351, 4357, 4363, 4369, 4373, 4379, 4387, 4397, 4409, 4411, 4421, 4423, 4427, 4429, 4439, 4451, 4453, 4469, 4471, 4477, 4483, 4489, 4513, 4517, 4523, 4537, 4541, 4547, 4549, 4561, 4577, 4579, 4589, 4601, 4607, 4619, 4621, 4631, 4633, 4643, 4651, 4661, 4663, 4673, 4679, 4687, 4693, 4699, 4709, 4717, 4727, 4733, 4741, 4747, 4751, 4759, 4763, 4769, 4783, 4801, 4807, 4847, 4853, 4861, 4867, 4871, 4877, 4883, 4891, 4939, 4943, 4951, 4973, 4979, 4981, 4987, 4999, 5003, 5009, 5017, 5027, 5039, 5041, 5051, 5053, 5057, 5059, 5069, 5083, 5099, 5101, 5107, 5113, 5119, 5143, 5147, 5153, 5167, 5171, 5177, 5179, 5191, 5207, 5219, 5231, 5237, 5249, 5251, 5261, 5263, 5273, 5281, 5291, 5293, 5303, 5309, 5317, 5323, 5329, 5339, 5347, 5357, 5363, 5371, 5377, 5381, 5389, 5393, 5399, 5413, 5431, 5437, 5477, 5483, 5491, 5497, 5501, 5507, 5513, 5573, 5581, 5603, 5611, 5629, 5633, 5639, 5647, 5669, 5671, 5683, 5687, 5689, 5699, 5713, 5731, 5737, 5743, 5749, 5773, 5777, 5783, 5797, 5801, 5807, 5821, 5837, 5849, 5861, 5867, 5881, 5891, 5893, 5903, 5911, 5921, 5923, 5933, 5939, 5947, 5953, 5959, 5969, 5987, 5993, 6007, 6011, 6019, 6023, 6029, 6043, 6061, 6067, 6107, 6121, 6131, 6203, 6211, 6233, 6241, 6259, 6263, 6269, 6277, 6299, 6301, 6317, 6329, 6343, 6361, 6367, 6373, 6379, 6403, 6407, 6413, 6427, 6431, 6437, 6451, 6467, 6497, 6509, 6533, 6541, 6551, 6553, 6563, 6583, 6589, 6599, 6617, 6623, 6637, 6653, 6673, 6691, 6697, 6737, 6751, 6757, 6761, 6773, 6871, 6889, 6893, 6907, 6931, 6947, 6949, 6973, 6997, 7003, 7009, 7037, 7057, 7061, 7067, 7109, 7121, 7141, 7181, 7213, 7229, 7253, 7283, 7321, 7327, 7367, 7381, 7391, 7493, 7501, 7519, 7577, 7589, 7603, 7627, 7673, 7687, 7691, 7739, 7757, 7769, 7771, 7801, 7813, 7849, 7859, 7877, 7883, 7933, 8011, 8021, 8123, 8149, 8159, 8191, 8219, 8251, 8269, 8303, 8317, 8401, 8431, 8441, 8443, 8473, 8581, 8587, 8627, 8651, 8663, 8837, 8839, 8887, 8923, 8933, 8951, 8957, 9017, 9061, 9071, 9073, 9109, 9137, 9211, 9391, 9419, 9467, 9517, 9587, 9617, 9701, 9733, 10331, 10363, 10471, 10541, 10679, 10951, 10993, 11591, 11801, 12013, 12361, 12407, 12569, 12619, 12731, 12851, 13037, 13297, 13309, 13621, 13829, 13879, 14143, 14251, 14297, 15371, 15557, 16187, 17261, 17891, 18437, 19067, 20161]
#z=(M+1).times.select{|i|!h[i]}
gets.to_i.times{
	puts z.include?(gets.to_i) ? :NO : :YES
}