Odd-Length Cycle
Time limit1sMemory limit128 MB
For each of t undirected graphs, decide whether it contains an odd-length cycle (equivalently, is not bipartite).
Problem
Given an undirected graph, determine whether it contains a cycle of odd length.
You are given a number of test cases, followed by graphs. For each graph, decide whether an odd-length cycle exists in it.
Input
The first line contains the number of test cases (). Then undirected graphs follow.
Each graph starts with two integers and , the number of vertices and the number of edges (, ). Each of the next lines contains two integers between and , the two endpoints of one edge.
Output
For each graph, print the answer on its own line. Print TAK if the graph contains a cycle of odd length (equivalently, the graph is not bipartite), and NIE otherwise.