C-algae is the Byteotians' favourite dish of their national cuisine. A c-algae has a very specific structure, defined recursively.
Disjoint union — take all cells and all connections of both K1 and K2.

Join — take all cells and all connections of both K1 and K2, and in addition connect every cell of K1 to every cell of K2.

Recently the hostile country of Bitotia started selling algae that imitate c-algae so closely that a fake is hard to tell apart from a genuine c-algae. The Byteotian government has therefore asked you to write a program that verifies whether a given algae is really a c-algae.
Write a program that reads the descriptions of several algae from standard input, determines which of them are proper c-algae, and writes the answers to standard output. Every connection is undirected.
The first line contains a single integer k (1≤k≤10) — the number of algae to examine. The descriptions of the k algae follow.
Each description begins with a line containing two integers n and m (1≤n≤10000, 0≤m≤100000) — the number of cells and the number of connections. The cells are numbered from 1 to n. Each of the next m lines contains two integers a and b (a=b, 1≤a,b≤n) describing an undirected connection between cells a and b. Each connection is given exactly once.
Output k lines. In the i-th line print:
TAK if the i-th algae is a proper c-algae,NIE otherwise.