Three-Bit Computers

No attempts yetTime limit1sMemory limit128 MB

Problem

Scientists in the Kingdom of Byteland set out to build a new kind of machine, the three-bit computer (TBC). Many expect that it will crack problems far too hard for ordinary computers. Along the way the team hit a number of engineering snags, and your job is to help them clear one of them.

Right now they are working on the memory initialization routine. A TBC has nn memory bits numbered 1,,n1, \dots, n. Each bit either holds one of three values (aa, bb, or cc) or is still uninitialized. The machine offers exactly two initialization operations:

  • Two consecutive uninitialized bits can be set to two different values.
  • Two consecutive bits, one uninitialized and the other holding a value xx, can be set to two different values, both of which must differ from xx (so the bit that held xx is overwritten as well).

For example, one valid initialization sequence for n=4n = 4 looks like this, where uu marks an uninitialized bit:

uuuuuuabucbbbabbuuuu \rightarrow uuab \rightarrow ucbb \rightarrow babb

Write a program that reads the values the memory should end up holding, decides whether reaching that state is possible, and prints the answer.

Input

The input describes between 11 and 1010 target memory configurations. The first line holds a single integer, the number of configurations. Each configuration then spans two lines. The first holds an integer lil_i (1li1000001 \le l_i \le 100000), the memory size of the ii-th configuration. The second holds a string of length lil_i over the letters aa, bb, cc, describing the configuration you want to reach.

Output

Print one line per configuration. For the ii-th configuration print TAK if the initialization is possible, and NIE otherwise.