The Fibonacci Game

No attempts yetTime limit1sMemory limit128 MB

Problem

Define the Fibonacci words fif_i as follows: f1=af_1 = a, f2=bf_2 = b, and for i3i \ge 3, fi=fi2fi1f_i = f_{i-2} f_{i-1}. In other words, the Fibonacci word with index ii is obtained by concatenating the words with indices i2i-2 and i1i-1, in that order. For example, f3=abf_3 = ab, f4=babf_4 = bab, and f5=abbabf_5 = abbab.

The Fibonacci game is played by two players on a single word made only of the letters a and b (this word is called the board). The players alternate moves; a single move consists of erasing any one Fibonacci word from the right end of the board. A player who cannot make a move loses. For a given word, determine whether the player who moves first can always win, assuming both players play optimally.

Write a program that reads the number of test cases and, for each one, reads the board on which the game is played from standard input, determines whether the first player can always win, and prints the answer to standard output.

Input

The first line contains one integer tt (1t101 \le t \le 10), the number of test cases. Each of the next tt lines describes one test case. Each line contains a positive integer nn (1n1000001 \le n \le 100\,000), followed by a single space and then a string of the letters a and b of length nn (with no spaces between the letters). This string is the board on which the game is played.

Output

Print tt lines. Each line contains the answer for one test case, in the same order as the input. Print TAK if the first player can always win, and NIE otherwise.