Island Alliances

아직 제출이 없습니다시간 제한5초메모리 제한1024 MB

문제

In a vast ocean there are nn islands numbered from 11 to nn, where each island constitutes a sovereign state.

However, the large number of states is making foreign policy a very complicated matter, so the inhabitants of the islands have decided to simplify things by joining into larger (but fewer) states. This endeavour has turned out to be easier said than done, because there are mm pairs of islands whose inhabitants distrust each other and refuse to be part of the same state.

The islanders have sent you qq proposals that you should process in order. The iith proposal calls for the state containing island a_ia\_i to merge with the state containing island b_ib\_i. If the two states contain a pair of islands whose inhabitants distrust each other the proposal should be rejected, but otherwise the proposal should be approved and all the islands in the two states will henceforth be part of the same state.

Please help the islanders figure out which proposals should be rejected and which should be approved!

입력

The input consists of:

  • One line with three integers nn, mm, and qq, the number of islands, the number of distrusting pairs of islands, and the number of proposals.
  • mm lines, the iith of which contains two integers u_iu\_i and v_iv\_i, where 1u_i,v_in1 \leq u\_i,v\_i \leq n, u_iv_iu\_i \neq v\_i, meaning that the inhabitants of islands u_iu\_i and v_iv\_i distrust each other. Each pair (u_i,v_i)(u\_i, v\_i) will be listed at most once.
  • qq lines, the iith of which contains two integers a_ia\_i and b_ib\_i, where 1a_i,b_in1 \leq a\_i,b\_i \leq n, describing the iith proposal. It is guaranteed that no proposal will ever call for a state to merge with itself, meaning that at the time when you receive the iith proposal, a_ia\_i and b_ib\_i are guaranteed to belong to different states.

출력

Output qq lines, where the iith line should be "REFUSE" if the iith proposal should be refused, or "APPROVE" if the iith proposal should be approved.