import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.Arrays; public class ilo { public static void resolve(IO io) throws IOException { int cnt = io.readInt(); for (long i = 0; i < cnt; i++) { long toCheck = io.readLong(); if (Arrays.binarySearch(results, toCheck) < 0) io.writeString("NIE\n"); else io.writeString("TAK\n"); } } public static void main(String[] args) throws IOException { SystemIO io = new SystemIO(); resolve(io); io.out.flush(); } static long[] results = { 1l, 2l, 3l, 4l, 5l, 6l, 8l, 9l, 10l, 13l, 15l, 16l, 21l, 24l, 25l, 26l, 34l, 39l, 40l, 42l, 55l, 63l, 64l, 65l, 68l, 89l, 102l, 104l, 105l, 110l, 144l, 165l, 168l, 169l, 170l, 178l, 233l, 267l, 272l, 273l, 275l, 288l, 377l, 432l, 440l, 441l, 442l, 445l, 466l, 610l, 699l, 712l, 714l, 715l, 720l, 754l, 987l, 1131l, 1152l, 1155l, 1156l, 1157l, 1165l, 1220l, 1597l, 1830l, 1864l, 1869l, 1870l, 1872l, 1885l, 1974l, 2584l, 2961l, 3016l, 3024l, 3025l, 3026l, 3029l, 3050l, 3194l, 4181l, 4791l, 4880l, 4893l, 4895l, 4896l, 4901l, 4935l, 5168l, 6765l, 7752l, 7896l, 7917l, 7920l, 7921l, 7922l, 7930l, 7985l, 8362l, 10946l, 12543l, 12776l, 12810l, 12815l, 12816l, 12818l, 12831l, 12920l, 13530l, 17711l, 20295l, 20672l, 20727l, 20735l, 20736l, 20737l, 20740l, 20761l, 20905l, 21892l, 28657l, 32838l, 33448l, 33537l, 33550l, 33552l, 33553l, 33558l, 33592l, 33825l, 35422l, 46368l, 53133l, 54120l, 54264l, 54285l, 54288l, 54289l, 54290l, 54298l, 54353l, 54730l, 57314l, 75025l, 85971l, 87568l, 87801l, 87835l, 87840l, 87841l, 87843l, 87856l, 87945l, 88555l, 92736l, 121393l, 139104l, 141688l, 142065l, 142120l, 142128l, 142129l, 142130l, 142133l, 142154l, 142298l, 143285l, 150050l, 196418l, 225075l, 229256l, 229866l, 229955l, 229968l, 229970l, 229971l, 229976l, 230010l, 230243l, 231840l, 242786l, 317811l, 364179l, 370944l, 371931l, 372075l, 372096l, 372099l, 372100l, 372101l, 372109l, 372164l, 372541l, 375125l, 392836l, 514229l, 589254l, 600200l, 601797l, 602030l, 602064l, 602069l, 602070l, 602072l, 602085l, 602174l, 602784l, 606965l, 635622l, 832040l, 953433l, 971144l, 973728l, 974105l, 974160l, 974168l, 974169l, 974170l, 974173l, 974194l, 974338l, 975325l, 982090l, 1028458l, 1346269l, 1542687l, 1571344l, 1575525l, 1576135l, 1576224l, 1576237l, 1576239l, 1576240l, 1576245l, 1576279l, 1576512l, 1578109l, 1589055l, 1664080l, 2178309l, 2496120l, 2542488l, 2549253l, 2550240l, 2550384l, 2550405l, 2550408l, 2550409l, 2550410l, 2550418l, 2550473l, 2550850l, 2553434l, 2571145l, 2692538l, 3524578l, 4038807l, 4113832l, 4124778l, 4126375l, 4126608l, 4126642l, 4126647l, 4126648l, 4126650l, 4126663l, 4126752l, 4127362l, 4131543l, 4160200l, 4356618l, 5702887l, 6534927l, 6656320l, 6674031l, 6676615l, 6676992l, 6677047l, 6677055l, 6677056l, 6677057l, 6677060l, 6677081l, 6677225l, 6678212l, 6684977l, 6731345l, 7049156l, 9227465l, 10573734l, 10770152l, 10798809l, 10802990l, 10803600l, 10803689l, 10803702l, 10803704l, 10803705l, 10803710l, 10803744l, 10803977l, 10805574l, 10816520l, 10891545l, 11405774l, 14930352l, 17108661l, 17426472l, 17472840l, 17479605l, 17480592l, 17480736l, 17480757l, 17480760l, 17480761l, 17480762l, 17480770l, 17480825l, 17481202l, 17483786l, 17501497l, 17622890l, 18454930l, 24157817l, 27682395l, 28196624l, 28271649l, 28282595l, 28284192l, 28284425l, 28284459l, 28284464l, 28284465l, 28284467l, 28284480l, 28284569l, 28285179l, 28289360l, 28318017l, 28514435l, 29860704l, 39088169l, 44791056l, 45623096l, 45744489l, 45762200l, 45764784l, 45765161l, 45765216l, 45765224l, 45765225l, 45765226l, 45765229l, 45765250l, 45765394l, 45766381l, 45773146l, 45819514l, 46137325l, 48315634l, 63245986l, 72473451l, 73819720l, 74016138l, 74044795l, 74048976l, 74049586l, 74049675l, 74049688l, 74049690l, 74049691l, 74049696l, 74049730l, 74049963l, 74051560l, 74062506l, 74137531l, 74651760l, 78176338l, 102334155l, 117264507l, 119442816l, 119760627l, 119806995l, 119813760l, 119814747l, 119814891l, 119814912l, 119814915l, 119814916l, 119814917l, 119814925l, 119814980l, 119815357l, 119817941l, 119835652l, 119957045l, 120789085l, 126491972l, 165580141l, 189737958l, 193262536l, 193776765l, 193851790l, 193862736l, 193864333l, 193864566l, 193864600l, 193864605l, 193864606l, 193864608l, 193864621l, 193864710l, 193865320l, 193869501l, 193898158l, 194094576l, 195440845l, 204668310l, 267914296l, 307002465l, 312705352l, 313537392l, 313658785l, 313676496l, 313679080l, 313679457l, 313679512l, 313679520l, 313679521l, 313679522l, 313679525l, 313679546l, 313679690l, 313680677l, 313687442l, 313733810l, 314051621l, 316229930l, 331160282l, 433494437l, 496740423l, 505967888l, 507314157l, 507510575l, 507539232l, 507543413l, 507544023l, 507544112l, 507544125l, 507544127l, 507544128l, 507544133l, 507544167l, 507544400l, 507545997l, 507556943l, 507631968l, 508146197l, 511670775l, 535828592l, 701408733l, 803742888l, 818673240l, 820851549l, 821169360l, 821215728l, 821222493l, 821223480l, 821223624l, 821223645l, 821223648l, 821223649l, 821223650l, 821223658l, 821223713l, 821224090l, 821226674l, 821244385l, 821365778l, 822197818l, 827900705l, 866988874l, 1300483311l, 1324641128l, 1328165706l, 1328679935l, 1328754960l, 1328765906l, 1328767503l, 1328767736l, 1328767770l, 1328767775l, 1328767776l, 1328767778l, 1328767791l, 1328767880l, 1328768490l, 1328772671l, 1328801328l, 1328997746l, 1330344015l, 1339571480l, 1402817466l, 2104226199l, 2143314368l, 2149017255l, 2149849295l, 2149970688l, 2149988399l, 2149990983l, 2149991360l, 2149991415l, 2149991423l, 2149991424l, 2149991425l, 2149991428l, 2149991449l, 2149991593l, 2149992580l, 2149999345l, 2150045713l, 2150363524l, 2152541833l, 2167472185l, 3467955496l, 3477182961l, 3478529230l, 3478725648l, 3478754305l, 3478758486l, 3478759096l, 3478759185l, 3478759198l, 3478759200l, 3478759201l, 3478759206l, 3478759240l, 3478759473l, 3478761070l, 3478772016l, 3478847041l, 3479361270l, 3482885848l, 3507043665l, 5611269864l, 5626200216l, 5628378525l, 5628696336l, 5628742704l, 5628749469l, 5628750456l, 5628750600l, 5628750621l, 5628750624l, 5628750625l, 5628750626l, 5628750634l, 5628750689l, 5628751066l, 5628753650l, 5628771361l, 5628892754l, 5629724794l, 5635427681l, 9103383177l, 9106907755l, 9107421984l, 9107497009l, 9107507955l, 9107509552l, 9107509785l, 9107509819l, 9107509824l, 9107509825l, 9107509827l, 9107509840l, 9107509929l, 9107510539l, 9107514720l, 9107543377l, 9107739795l, 9109086064l, 9118313529l, }; interface IO { int readInt() throws IOException; long readLong() throws IOException; String readLine() throws IOException; void writeString(String str) throws IOException; } static class SystemIO implements IO { StringBuilder b = new StringBuilder(); BufferedInputStream in = new BufferedInputStream(System.in); PrintStream out = new PrintStream(new BufferedOutputStream(System.out)); int skipWhitespace() throws IOException { int r = -1; do { r = in.read(); if (r < 0) break; } while (Character.isWhitespace(r)); return r; } public void readDigit() throws IOException { b.setLength(0); int r = skipWhitespace(); while (Character.isDigit(r)) { b.append((char) r); r = in.read(); } } @Override public int readInt() throws IOException { readDigit(); return Integer.parseInt(b.toString()); } @Override public long readLong() throws IOException { readDigit(); return Long.parseLong(b.toString()); } @Override public String readLine() throws IOException { b.setLength(0); int r = skipWhitespace(); while (r != 10) { if (r == -1) break; b.append((char) r); r = in.read(); } return b.toString(); } @Override public void writeString(String str) throws IOException { out.write(str.getBytes()); } } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.Arrays; public class ilo { public static void resolve(IO io) throws IOException { int cnt = io.readInt(); for (long i = 0; i < cnt; i++) { long toCheck = io.readLong(); if (Arrays.binarySearch(results, toCheck) < 0) io.writeString("NIE\n"); else io.writeString("TAK\n"); } } public static void main(String[] args) throws IOException { SystemIO io = new SystemIO(); resolve(io); io.out.flush(); } static long[] results = { 1l, 2l, 3l, 4l, 5l, 6l, 8l, 9l, 10l, 13l, 15l, 16l, 21l, 24l, 25l, 26l, 34l, 39l, 40l, 42l, 55l, 63l, 64l, 65l, 68l, 89l, 102l, 104l, 105l, 110l, 144l, 165l, 168l, 169l, 170l, 178l, 233l, 267l, 272l, 273l, 275l, 288l, 377l, 432l, 440l, 441l, 442l, 445l, 466l, 610l, 699l, 712l, 714l, 715l, 720l, 754l, 987l, 1131l, 1152l, 1155l, 1156l, 1157l, 1165l, 1220l, 1597l, 1830l, 1864l, 1869l, 1870l, 1872l, 1885l, 1974l, 2584l, 2961l, 3016l, 3024l, 3025l, 3026l, 3029l, 3050l, 3194l, 4181l, 4791l, 4880l, 4893l, 4895l, 4896l, 4901l, 4935l, 5168l, 6765l, 7752l, 7896l, 7917l, 7920l, 7921l, 7922l, 7930l, 7985l, 8362l, 10946l, 12543l, 12776l, 12810l, 12815l, 12816l, 12818l, 12831l, 12920l, 13530l, 17711l, 20295l, 20672l, 20727l, 20735l, 20736l, 20737l, 20740l, 20761l, 20905l, 21892l, 28657l, 32838l, 33448l, 33537l, 33550l, 33552l, 33553l, 33558l, 33592l, 33825l, 35422l, 46368l, 53133l, 54120l, 54264l, 54285l, 54288l, 54289l, 54290l, 54298l, 54353l, 54730l, 57314l, 75025l, 85971l, 87568l, 87801l, 87835l, 87840l, 87841l, 87843l, 87856l, 87945l, 88555l, 92736l, 121393l, 139104l, 141688l, 142065l, 142120l, 142128l, 142129l, 142130l, 142133l, 142154l, 142298l, 143285l, 150050l, 196418l, 225075l, 229256l, 229866l, 229955l, 229968l, 229970l, 229971l, 229976l, 230010l, 230243l, 231840l, 242786l, 317811l, 364179l, 370944l, 371931l, 372075l, 372096l, 372099l, 372100l, 372101l, 372109l, 372164l, 372541l, 375125l, 392836l, 514229l, 589254l, 600200l, 601797l, 602030l, 602064l, 602069l, 602070l, 602072l, 602085l, 602174l, 602784l, 606965l, 635622l, 832040l, 953433l, 971144l, 973728l, 974105l, 974160l, 974168l, 974169l, 974170l, 974173l, 974194l, 974338l, 975325l, 982090l, 1028458l, 1346269l, 1542687l, 1571344l, 1575525l, 1576135l, 1576224l, 1576237l, 1576239l, 1576240l, 1576245l, 1576279l, 1576512l, 1578109l, 1589055l, 1664080l, 2178309l, 2496120l, 2542488l, 2549253l, 2550240l, 2550384l, 2550405l, 2550408l, 2550409l, 2550410l, 2550418l, 2550473l, 2550850l, 2553434l, 2571145l, 2692538l, 3524578l, 4038807l, 4113832l, 4124778l, 4126375l, 4126608l, 4126642l, 4126647l, 4126648l, 4126650l, 4126663l, 4126752l, 4127362l, 4131543l, 4160200l, 4356618l, 5702887l, 6534927l, 6656320l, 6674031l, 6676615l, 6676992l, 6677047l, 6677055l, 6677056l, 6677057l, 6677060l, 6677081l, 6677225l, 6678212l, 6684977l, 6731345l, 7049156l, 9227465l, 10573734l, 10770152l, 10798809l, 10802990l, 10803600l, 10803689l, 10803702l, 10803704l, 10803705l, 10803710l, 10803744l, 10803977l, 10805574l, 10816520l, 10891545l, 11405774l, 14930352l, 17108661l, 17426472l, 17472840l, 17479605l, 17480592l, 17480736l, 17480757l, 17480760l, 17480761l, 17480762l, 17480770l, 17480825l, 17481202l, 17483786l, 17501497l, 17622890l, 18454930l, 24157817l, 27682395l, 28196624l, 28271649l, 28282595l, 28284192l, 28284425l, 28284459l, 28284464l, 28284465l, 28284467l, 28284480l, 28284569l, 28285179l, 28289360l, 28318017l, 28514435l, 29860704l, 39088169l, 44791056l, 45623096l, 45744489l, 45762200l, 45764784l, 45765161l, 45765216l, 45765224l, 45765225l, 45765226l, 45765229l, 45765250l, 45765394l, 45766381l, 45773146l, 45819514l, 46137325l, 48315634l, 63245986l, 72473451l, 73819720l, 74016138l, 74044795l, 74048976l, 74049586l, 74049675l, 74049688l, 74049690l, 74049691l, 74049696l, 74049730l, 74049963l, 74051560l, 74062506l, 74137531l, 74651760l, 78176338l, 102334155l, 117264507l, 119442816l, 119760627l, 119806995l, 119813760l, 119814747l, 119814891l, 119814912l, 119814915l, 119814916l, 119814917l, 119814925l, 119814980l, 119815357l, 119817941l, 119835652l, 119957045l, 120789085l, 126491972l, 165580141l, 189737958l, 193262536l, 193776765l, 193851790l, 193862736l, 193864333l, 193864566l, 193864600l, 193864605l, 193864606l, 193864608l, 193864621l, 193864710l, 193865320l, 193869501l, 193898158l, 194094576l, 195440845l, 204668310l, 267914296l, 307002465l, 312705352l, 313537392l, 313658785l, 313676496l, 313679080l, 313679457l, 313679512l, 313679520l, 313679521l, 313679522l, 313679525l, 313679546l, 313679690l, 313680677l, 313687442l, 313733810l, 314051621l, 316229930l, 331160282l, 433494437l, 496740423l, 505967888l, 507314157l, 507510575l, 507539232l, 507543413l, 507544023l, 507544112l, 507544125l, 507544127l, 507544128l, 507544133l, 507544167l, 507544400l, 507545997l, 507556943l, 507631968l, 508146197l, 511670775l, 535828592l, 701408733l, 803742888l, 818673240l, 820851549l, 821169360l, 821215728l, 821222493l, 821223480l, 821223624l, 821223645l, 821223648l, 821223649l, 821223650l, 821223658l, 821223713l, 821224090l, 821226674l, 821244385l, 821365778l, 822197818l, 827900705l, 866988874l, 1300483311l, 1324641128l, 1328165706l, 1328679935l, 1328754960l, 1328765906l, 1328767503l, 1328767736l, 1328767770l, 1328767775l, 1328767776l, 1328767778l, 1328767791l, 1328767880l, 1328768490l, 1328772671l, 1328801328l, 1328997746l, 1330344015l, 1339571480l, 1402817466l, 2104226199l, 2143314368l, 2149017255l, 2149849295l, 2149970688l, 2149988399l, 2149990983l, 2149991360l, 2149991415l, 2149991423l, 2149991424l, 2149991425l, 2149991428l, 2149991449l, 2149991593l, 2149992580l, 2149999345l, 2150045713l, 2150363524l, 2152541833l, 2167472185l, 3467955496l, 3477182961l, 3478529230l, 3478725648l, 3478754305l, 3478758486l, 3478759096l, 3478759185l, 3478759198l, 3478759200l, 3478759201l, 3478759206l, 3478759240l, 3478759473l, 3478761070l, 3478772016l, 3478847041l, 3479361270l, 3482885848l, 3507043665l, 5611269864l, 5626200216l, 5628378525l, 5628696336l, 5628742704l, 5628749469l, 5628750456l, 5628750600l, 5628750621l, 5628750624l, 5628750625l, 5628750626l, 5628750634l, 5628750689l, 5628751066l, 5628753650l, 5628771361l, 5628892754l, 5629724794l, 5635427681l, 9103383177l, 9106907755l, 9107421984l, 9107497009l, 9107507955l, 9107509552l, 9107509785l, 9107509819l, 9107509824l, 9107509825l, 9107509827l, 9107509840l, 9107509929l, 9107510539l, 9107514720l, 9107543377l, 9107739795l, 9109086064l, 9118313529l, }; interface IO { int readInt() throws IOException; long readLong() throws IOException; String readLine() throws IOException; void writeString(String str) throws IOException; } static class SystemIO implements IO { StringBuilder b = new StringBuilder(); BufferedInputStream in = new BufferedInputStream(System.in); PrintStream out = new PrintStream(new BufferedOutputStream(System.out)); int skipWhitespace() throws IOException { int r = -1; do { r = in.read(); if (r < 0) break; } while (Character.isWhitespace(r)); return r; } public void readDigit() throws IOException { b.setLength(0); int r = skipWhitespace(); while (Character.isDigit(r)) { b.append((char) r); r = in.read(); } } @Override public int readInt() throws IOException { readDigit(); return Integer.parseInt(b.toString()); } @Override public long readLong() throws IOException { readDigit(); return Long.parseLong(b.toString()); } @Override public String readLine() throws IOException { b.setLength(0); int r = skipWhitespace(); while (r != 10) { if (r == -1) break; b.append((char) r); r = in.read(); } return b.toString(); } @Override public void writeString(String str) throws IOException { out.write(str.getBytes()); } } } |