#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);}) #define rd_skip() while(*rp++>=48) #define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;}) #define wt(v) ({unsigned _z=v;int _n=0;ulong _d=0;while(++_n,_d=_d<<8|0x30|_z%10,_z/=10);*(ulong*)wp=_d;wp+=_n;}) #define rep(v,e) for(typeof(e) v=0;v=a?v:a) typedef unsigned long ulong; char wbuf[1<<25]; void sort_aux(unsigned*a,unsigned*b,int n){ int c[256]; for(int i=0;i<256;++i){ c[i]=0; } for(int i=0;i>8|a[i]<<24; } } void sort(unsigned*a,int n){ unsigned*b=(unsigned*)wbuf; sort_aux(a,b,n); sort_aux(b,a,n); sort_aux(a,b,n); sort_aux(b,a,n); } unsigned g[200000]; int h[200000]; int t[200000]; int e[18][200000]; int main(){ rd_init(); int n=rd(); rep(i,n){ h[i]=g[i]=rd(); } sort(g,n); rep(i,n){ int x=h[i]; int a=0,b=n; while(a+1>1; if(g[c]<=x){ a=c; }else{ b=c; } } h[i]=a; } rep(i,n){ int x=rd(); int a=0,b=n; while(a+1>1; if(g[c]<=x){ a=c; }else{ b=c; } } t[i]=a; chmax(e[0][h[i]],a); } rep3(i,1,200000){ chmax(e[0][i],e[0][i-1]); } rep3(k,1,18){ rep(i,200000){ e[k][i]=e[k-1][e[k-1][i]]; } } char*wp=wbuf; rd_skip(); while(*rp){ int a=rd()-1; int b=rd()-1; if(t[a]>=h[b]){ *wp++='1'; }else{ int c=t[a]; int z=1; rrep(k,18){ if(e[k][c]