#P5913. [POI 2004] KAG

[POI 2004] KAG

Problem Description

Input Format

The first line contains an integer kk, indicating there are kk test cases.

For each test case, it starts with two integers nn and mm. Then follow mm lines, each containing two integers describing an edge.

Output Format

Output a total of kk lines. For each line, output one decision: if the graph is c-algae, output TAK; otherwise, output NIE.

3
3 2
1 2
2 3
4 3
1 2
2 3
3 4
3 3
1 2
2 3
3 1
TAK
NIE
TAK

Hint

For 100%100\% of the testdata, 1k101\le k\le10, 1n1041\le n\le10^4, 0m1050\le m\le10^5.

Translated by ChatGPT 5