Marble

Time limit1sMemory limit128 MB

Problem

Minhyeok plays with Jisu every Friday. This Friday marks ten years since they became friends, so they decide to play a special game. Minhyeok reserves a dirt playground, and Jisu brings one small marble.

First, Minhyeok draws a directed graph on the ground with a twig. Each vertex has at most one outgoing edge. Then he places the marble on one vertex. If the current vertex has an outgoing edge, the marble follows that edge, and the same process repeats at the next vertex. If the marble reaches a vertex with no outgoing edge, it stops there. In some cases the marble may move forever, and some vertices may never be visited.

Minhyeok asks the following two kinds of questions to check whether Jisu understands the rules.

  • 1 X: If the marble is placed on vertex X and does not move forever, ask for the number of the vertex where it stops.
  • 2 X: Delete the outgoing edge from vertex X. This question is given only for a vertex that currently has an outgoing edge.

Given Minhyeok's questions, write a program that prints Jisu's answers.

Input

The first line contains the number of vertices N. (1 <= N <= 300000)

The second line contains N integers separated by spaces. The i-th integer is the destination of the outgoing edge from vertex i. Vertices are numbered from 1, and 0 means that the vertex has no outgoing edge.

The third line contains the number of questions Q. (1 <= Q <= 300000)

Each of the next Q lines contains one question in the format described above.

Output

For each question of type 1 X, print one answer on its own line. If the marble stops at a vertex with no outgoing edge, print that vertex number. If the marble never stops, print CIKLUS.