#P5913. [POI 2004] KAG
[POI 2004] KAG
Problem Description

Input Format
The first line contains an integer , indicating there are test cases.
For each test case, it starts with two integers and . Then follow lines, each containing two integers describing an edge.
Output Format
Output a total of 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 of the testdata, , , .
Translated by ChatGPT 5