// https://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=4683042#1 //#include #include #include #include using namespace std; using UL=unsigned int; using LL=long long; using ULL=unsigned long long; #define rep(i,n) for(UL i=0; i<(n); i++) struct Query{ UL l,r,x,i; }; bool cmp_r(const Query& l,const Query& r){ return l.r>r.r; } UL N,K,Q; UL S[100000]; UL T[100000]; UL rT[100000]; UL A[100000][2]; vector Que[2][300]; UL L,R; UL ans[100000]; void exe(UL l, UL r){ for(int p=R; pr; p--) swap(S[A[p-1][0]],S[A[p-1][1]]); for(int p=L; pl; p--){ swap(rT[T[A[p-1][0]]],rT[T[A[p-1][1]]]); swap(T[A[p-1][0]],T[A[p-1][1]]); } L=l; R=r; } int main(){ scanf("%u%u%u",&N,&K,&Q); L=R=0; rep(i,K) rep(j,2){ scanf("%u",&A[i][j]); A[i][j]--; } rep(q,Q){ //UL c,l,r,x; scanf("%u%u%u%u",&c,&l,&r,&x); c--; l--; x--; UL c=1,l,r,x; scanf("%u%u%u",&l,&r,&x); c--; l--; x--; Que[c][l*300/K].push_back(Query{l,r,x,q}); } rep(c,2) rep(i,300) sort(Que[c][i].begin(),Que[c][i].end(),cmp_r); rep(c,2){ rep(i,N)S[i]=i; rep(i,N)T[i]=i; rep(i,N)rT[i]=i; L=R=0; rep(i,300){ for(Query& q:Que[c][i]){ if(c==0){ exe(q.l,q.r); ans[q.i]=rT[S[q.x]]+1; } else { exe(q.r,q.l); ans[q.i]=rT[S[q.x]]+1; } } } } rep(i,Q) printf("%u\n",ans[i]); return 0; }