#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define lsb(x) (x&(-x))
#define pii pair<int,int>
#define ss second
#define ff first
#define piii pair<int,pii>
#define debu(x) (cerr << #x << " = "<< x << "\n")
#define debu2(x,y) (cerr << #x << " = "<< x << " " << #y << " = " << y << "\n")
#define debu3(x,y,z) (cerr << #x << " = "<< x << " " << #y << " = " << y << " " << #z << " = " << z<< "\n")
#define bitout(x,y) {\
cerr << #x << " : ";\
for (int justforbits = y; justforbits >=0; justforbits--)cout << (((1 << justforbits) & x)>=1);\
cout << "\n";\
}
#define rangeout(j,rangestart,rangeend) {\
cerr << "outputting " << #j<< ":\n";\
for (int forrang = rangestart; forrang <= rangeend; forrang++)cerr << j[forrang] << " ";\
cerr<<"\n";\
}
#define c1 {cerr << "Checkpoint 1! \n\n";cerr.flush();}
#define c2 {cerr << "Checkpoint 2! \n\n";cerr.flush();}
#define c3 {cerr << "Checkpoint 3! \n\n";cerr.flush();}
#define c4 {cerr << "Checkpoint 4! \n\n";cerr.flush();}
signed main()
{
int t1,t2,t3,t4;
mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;cin>>n;
vector<pii>ppl(n+1);
for(int a=1;a<=n;a++)cin>>ppl[a].ff;
for(int a=1;a<=n;a++)cin>>ppl[a].ss;
int q;cin>>q;
while(q--)
{
cin>>t1>>t2;
vector<pii>curra,currb;
vector<bool>canstraight(n+1,false);
vector<int>mygift,myreq;
mygift.pb(0);myreq.pb(0);
for(int i=t1;i<=t2;i++)
{
curra.pb(mp(ppl[i].ff,i));
currb.pb(mp(ppl[i].ss,i));
mygift.pb(ppl[i].ff);myreq.pb(ppl[i].ss);
}
sort(curra.begin(),curra.end());
sort(currb.begin(),currb.end());
sort(mygift.begin()+1,mygift.end());
sort(myreq.begin()+1,myreq.end());
for(int i=0;i<curra.size();i++)
{
if(curra[i].ss!=currb[i].ss)
{
canstraight[i+1]=true;
}
}
int enn=mygift.size();
vector<int>cannots;
int prev=LLONG_MIN;
vector<bool>iscannot(enn+1,false);
for(int i=1;i<=enn;i++)
{
int curr=mygift[i];
t1=upper_bound(myreq.begin()+1,myreq.end(),curr)-myreq.begin();
t1--;
if(t1==i&&!canstraight[i])
{
iscannot[i]=true;
if(prev==i-1){cannots.pb(i-1);}
prev=i;
}
}
if(cannots.size()!=0||(iscannot[1]||iscannot[enn-1])){cout<<"No\n";}
else cout<<"Yes\n";
}
}