#graph504. Riddle
Riddle
Riddle
Problem Source
PA 2010
Problem Description
An undirected graph with vertices and edges is divided into parts. Each part contains some of the vertices.
Select some "key vertices" such that every part contains exactly one key vertex, and at least one endpoint of every edge is a key vertex.
Input Format
The first line contains three integers .
The next lines each contain two integers , indicating an edge between and .
The next lines each begin with an integer , the number of vertices in that part, followed by integers: the vertex indices belonging to that part.
For all test cases, , , , and .
Output Format
If such a selection is possible, output TAK; otherwise output NIE.
Sample Input
6 5 2
1 2
3 1
1 4
5 2
6 2
3 3 4 2
3 1 6 5
Sample Output
TAK