#include using namespace std; #define int long long void solve(); signed main(){ cin.tie(nullptr)->sync_with_stdio(false); cout<>T; while(T--)solve(); return 0; } void solve(){ int N;cin>>N; vectorL(N),A(N); vector>G(N); for(int i=0;i>L[i]>>A[i]; A[i]--; G[A[i]].push_back(i+1); } queueque; vectore(N,-1); vectorc(N,2e9); que.push(0); e[0]=1; c[0]=1; while(!que.empty()){ int u=que.front();que.pop(); for(int v:G[u])if(e[v]==-1){ e[v]=max(e[u],L[v-1]); c[v]=e[v]; que.push(v); } } sort(c.begin(),c.end()); int Q;cin>>Q; while(Q--){ int type;cin>>type; if(type==1){ int x;cin>>x; cout<>y; y--; cout<