#P6378. [PA 2010] Riddle
[PA 2010] Riddle
Description
An undirected graph with vertices and edges is divided into parts. Each part contains some vertices.
Please choose some key vertices such that each part has exactly one key vertex, and each edge has at least one endpoint that is a key vertex.
Input Format
The first line contains three integers .
The next lines each contain two integers , indicating that there is an edge between and .
The next lines: the first integer is , meaning this part has vertices; then follow integers, which are the indices of the vertices in this part.
Output Format
If it is possible, output TAK; otherwise output NIE.
6 5 2
1 2
3 1
1 4
5 2
6 2
3 3 4 2
3 1 6 5
TAK
Hint
Constraints
For all testdata, it is guaranteed that , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号