#include using namespace std; #define rep(i,n) for(int i=0; i; using TU = tuple; using vint = vector; using vvint = vector; using vvvint = vector; using vll = vector; using vvll = vector; using vvvll = vector; template istream &operator>>(istream &is,vector &v){for(T &in:v){is>>in;}return is;} template ostream &operator<<(ostream &os,vector &v){for(int i=0;i<(int)v.size();i++){os< istream &operator>>(istream &is,vector> &v){for(vector &in:v){is>>in;}return is;} template ostream &operator<<(ostream &os,vector> &v){for(vector &out:v){os<>n; vector

waza(n); for(int i=1;i>l>>a; a--; waza[i]={l,a}; } const ll INF=1e16; vll lowerLv(n,INF); // vll numLowerLv(n+10,INF); // numLowerLv[0]=-1; vector> nxtWaza(n); for(int i=1;ivoid{ cnt++; lowerLv[now]=lv; // numLowerLv[cnt]=min(numLowerLv[cnt],lv); for(auto [l,i]:nxtWaza[now]){ f(f,i,max(lv,l),cnt); } }; searchLowerLv(searchLowerLv,0,0,0); auto copy=lowerLv; Sort(lowerLv); int q;cin>>q; rep(_,q) { int c,x;cin>>c>>x; if(c==1){ // int res=upper_bound(numLowerLv.begin(),numLowerLv.end(),x)-numLowerLv.begin(); // res--; // cout<< res <<'\n'; int res=upper_bound(copy.begin(),copy.end(),x)-copy.begin(); // res--; cout<< res <<'\n'; }else{ x--; if(lowerLv[x]!=INF) cout<< lowerLv[x] <<'\n'; else cout<< -1 <<'\n'; } } return 0; }