#include <bits/stdc++.h>
using namespace std;
int n,q,ver[300010];
int main(){
freopen("marbles.in","r",stdin);
freopen("marbles.out","w",stdout);
int p,k,x;
scanf("%d",&n);
for (int i=1;i<=n;i++){
scanf("%d",&p);
ver[i]=p;
}
scanf("%d",&q);
int w;
for (int t=1;t<=q;t++){
scanf("%d %d",&k,&x);
if (k==1){
if (q*n>1000000000){
printf("CIKLUS\n");
continue;
}
for (w=0;ver[x];w++){
x=ver[x];
if (w>n) break;
}
if (w>n) printf("CIKLUS\n");
else printf("%d\n",x);
}
else ver[x]=0;
}
return 0;
}