#include using namespace std; typedef long long ll; typedef long double ld; typedef pair pll; const ll LongINF=1000000000000000000; const int INF=1000000007; const int dx[]={0,1,0,-1}; const int dy[]={1,0,-1,0}; template inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;} template inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;} template T GCD(T a, Y b){if(aT LCM(T a,Y b){return (a*b)/GCD(a,b);} void clear(queue> &q){queue> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない using vi=vector; using vii=vector; #define REP(i,a,b) for(ll i=(a);i<(b);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define rv reverse #define ALL(a) (a).begin(),(a).end() #define decimal(x) fixed<>N; vi vertex(N+1,-1); vector> skills(N+1); vii graph(N+1); REP(i,2,N+1){ int l,a; cin>>l>>a; skills[i]={l,a}; } REP(i,2,N+1){ graph[skills[i].second].pb(i); } queue>que; que.push({1,1}); while(!que.empty()){ auto [x,level]=que.front(); que.pop(); for(auto y:graph[x]){ if(vertex[y]!=-1)continue; vertex[y]=max(level,skills[y].first); que.push({y,vertex[y]}); } } vi sortedSkills; sortedSkills.pb(1); rep(i,N+1){ if(vertex[i]>0)sortedSkills.pb(vertex[i]); } sort(ALL(sortedSkills)); int Q; cin>>Q; rep(q,Q){ int p; cin>>p; if(p==1){ int x; cin>>x; cout<>y; cout<