Riddle

No attempts yetTime limit3sMemory limit1024 MB

Problem

The evil sorcerer Voldebyte has imprisoned the brave knight Bytter the Bold in his tower. As is his custom, Voldebyte promises to free Bytter once he solves one of his (still unsolved) riddles. Because Bytter managed to kill Voldebyte's pet dragon and nearly killed Voldebyte himself, Voldebyte has chosen an especially hard riddle. Here is the riddle he poses to Bytter:

Byteland is divided into kk counties, containing nn towns in total. In addition, some pairs of towns are connected by bidirectional roads. I want to choose one town in each county to be its capital so that, for every road, at least one of its two endpoints is a capital. Is this possible?

Help poor Bytter and solve the riddle for him.

Input

The first line contains three integers: nn (1n1061 \le n \le 10^6), the number of towns; mm (0m1060 \le m \le 10^6), the number of roads; and kk (1kn1 \le k \le n), the number of counties. The towns are numbered from 11 to nn.

Each of the next mm lines contains two integers aia_i and bib_i (1ai,bin1 \le a_i, b_i \le n, aibia_i \ne b_i), meaning there is a road between towns aia_i and bib_i. No pair of towns is connected by more than one road.

Each of the next kk lines describes one county. The jj-th of these lines starts with an integer wjw_j (1wjn1 \le w_j \le n), the number of towns in county jj, followed by wjw_j distinct integers, the numbers of the towns in county jj. The sum of all wjw_j equals nn.

Output

Print a single line. If it is possible to choose the capitals so that every road has at least one capital endpoint, print TAK (which means yes in Polish). Otherwise print NIE (which means no in Polish).