#P6351. [PA 2011] Hard Choice

[PA 2011] Hard Choice

Description

There is an undirected graph with nn vertices and mm edges.

There are qq queries. Each query contains a character optopt and two integers x,yx, y.

If optopt is ZZ, it means a deletion operation: delete the edge (x,y)(x, y). It is guaranteed that the edge (x,y)(x, y) has not been deleted before, but it is not guaranteed that the edge exists in the current graph (that is, it is possible to delete all edges).

If optopt is PP, it means a query: ask whether there are two completely different paths between xx and yy. “Completely different” means the two paths do not share any edge, but they may share vertices.

Input Format

The first line contains three integers n,m,qn, m, q, with the same meaning as in the statement.

The next mm lines each contain two integers x,yx, y, indicating that there is an undirected edge between xx and yy.

The next qq lines each contain a character optopt and two integers x,yx, y, with the same meaning as in the statement.

Output Format

For each query with optopt equal to PP, if there exist two completely different paths, output one line with the string TAK. Otherwise, output one line with the string NIE.

7 8 7
1 2
1 3
1 4
2 3
3 4
3 7
7 4
5 6
Z 1 4
P 1 3
P 2 4
Z 1 3
P 1 3
Z 6 5
P 5 6

TAK
TAK
NIE
NIE

Hint

Constraints: 2n1052\leq n\leq 10^5, 1m,q1051\leq m,q\leq 10^5. It is guaranteed that the input is valid and there are no multiple edges or self-loops.

Translated by ChatGPT 5