#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int main(){ int n; cin>>n; vector dp(n,vector(20,0)); vector h(n),t(n); rep(i,n){ scanf("%d",&h[i]); } vector is; rep(i,n){ scanf("%d",&t[i]); is.push_back(i); } sort(is.begin(),is.end(),[&](int x,int y){ return h[x] hs(n); rep(i,n){ hs[i] = h[is[i]]; } vector rui(n); rep(i,n){ rui[i] = is[i]; if(i!=0){ if(t[rui[i]]>q; rep(_,q){ int a,b; scanf("%d %d",&a,&b); a--,b--; if(dp[a][0]==-1){ cout<<-1<=h[b]){ cout<<1<=0;i--){ if(h[b]>t[dp[cp][i]]){ cur |= 1<