#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef  long long int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[500005],b[500050],dp[500005]={0},parent[500005]={0},nxt[500005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[500005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
/******************************************/
ll solve(ll son,ll y){
     if(y>=n){
        dp[son]=nb;
        return son ;
     }
     ll z=0,idxb=son;
     ll nxtt=nxt[b[son]];
     ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),son)-v[nxtt].begin();
     if(idx!=v[nxtt].size()){
        idxb=v[nxtt][idx];
          // idxb=parent[idxb];
            z=solve(parent[idxb],y+dp[idxb]);
     }
     nb+=dp[idxb];
    if(z!=-1)dp[son]=nb;
    else dp[son]=z;
     parent[son]=z;
     return z;
}

vector<ll> tree[10000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   ll t;
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
      parent[i]=i;
      dp[i]=1;
   }
   for(i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
   for(i=1;i<=m;i++){
       if(dp[i]==n){
          vv.pb({i,parent[i]});
          continue;
       }
       if(dp[i]==-1){
          dp[i]=1;
          parent[i]=i;
       }
       nb=1;
       //cout<<i<<" "<<dp[i]<<parent[i]<<endl;
       z=solve(i,1);
      /* if(z!=-1){
            parent[i]=z;
            dp[i]=dp[i]+dp[parent[i]]-1;
       }*/
      if(dp[i]>=(n)&&parent[i]!=0) vv.pb({i,parent[i]});
   }
  // for(i=1;i<=m;i++)cout<<i<<" "<<" "<<dp[i]<<" "<<parent[i]<<" "<<b[parent[i]]<<endl;
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef   int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[200055],b[200050],nxt[200505];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[200050],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
ll up[200005][20];
/******************************************/
void solve(){
     ll i,j;
     up[m+1][0]=-1;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=-1;
     }
     for(ll j=1;j<20;j++){
        for(i=1;i<=m;i++)if(up[i][j-1]!=-1)up[i][j]=up[up[i][j-1]][j-1];
     }
     for(i=1;i<=m;i++){
        ll bsup=i;
        ll x=n-1;
        for(j=19;j>=0;j--){
            if((1<<j)<=x){
                x-=(1<<j);
                if(bsup!=-1)bsup=up[bsup][j];
            }
        }
        if(bsup!=-1)vv.pb({i,bsup});
     }
}

vector<ll> tree[8000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
   }
   for(i=1;i<=n;i++){
    sort(v[i].begin(),v[i].end());
   }
   memset(up,-1,sizeof(up));
   solve();
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    if(n)build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        res=0;
        if(!n){
            s+='0';
            continue;
        }
        idx=lower_bound(b+1,b+1+n,x)-b;
        if(idx<=n)res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef  long long int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[500005],b[500050],dp[500005]={0},parent[500005]={0},nxt[500005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[500005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
/******************************************/
ll solve(ll i,ll son,ll y){
     if(y==n){
        return son ;
     }
     ll z=-1;
     ll nxtt=nxt[b[son]];
     ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),son)-v[nxtt].begin();
     if(idx!=v[nxtt].size()){
           ll idxb=v[nxtt][idx];
            z= solve(i,idxb,y+1);
     }
     nb++;
     dp[son]=nb;
     parent[son]=z;
     return z;
}

vector<ll> tree[10000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   ll t;
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
      parent[i]=i;
      dp[i]=1;
   }
   for(i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
   for(i=1;i<=m;i++){
       if(dp[i]==n){
          vv.pb({i,parent[i]});
          continue;
       }
       if(dp[i]==-1){
        dp[i]=1;
        parent[i]=i;
       }
       nb=1;
      //cout<<i<<" "<<dp[i]<<" "<<parent[i]<<endl;
        parent[i]=solve(i,parent[i],dp[i]);
        dp[i]=dp[i]+dp[parent[i]];
      /* dp[i]=dp[i]+dp[parent[i]];
       parent[i]=parent[parent[i]];*/
      if(dp[i]>=(n-1)&&parent[i]!=-1) vv.pb({i,parent[i]});
   }
  // for(i=1;i<=m;i++)if(i==18)cout<<b[i]<<" "<<" "<<dp[i]<<" "<<parent[i]<<" "<<b[parent[i]]<<endl;
   //for(i=60;i<=70;i++)cout<<b[i]<<" ";
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef  long long int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[500005],b[500050],dp[500005]={0},parent[500005]={0},nxt[500005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[500005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
/******************************************/
ll solve(ll son,ll y){
     if(y==n){
        dp[son]=nb;
        return son ;
     }
     ll z=-1;
     ll nxtt=nxt[b[son]];
     ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),son)-v[nxtt].begin();
     if(idx!=v[nxtt].size()){
           ll idxb=v[nxtt][idx];
          // idxb=parent[idxb];
            z= solve(idxb,y+1);
     }
     nb++;
    if(z!=-1)dp[son]=nb;
    else dp[son]=z;
     parent[son]=z;
     return z;
}

vector<ll> tree[10000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   ll t;
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
      parent[i]=i;
      dp[i]=1;
   }
   for(i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
   for(i=1;i<=m;i++){
       if(dp[i]==n){
          vv.pb({i,parent[i]});
          continue;
       }
       if(dp[i]==-1){
          continue;
       }
       nb=1;
       //cout<<i<<" "<<dp[i]<<parent[i]<<endl;
       z=solve(i,dp[i]);
       if(z!=-1){
            parent[i]=z;
            dp[i]=dp[i]+dp[parent[i]]-1;
       }
      if(dp[i]>=(n)&&parent[i]!=-1) vv.pb({i,parent[i]});
   }
  // for(i=1;i<=m;i++)cout<<i<<" "<<" "<<dp[i]<<" "<<parent[i]<<" "<<b[parent[i]]<<endl;
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef   int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[200055],b[200050],nxt[200505];
set<ll>stres;
string s;
vector<ll>v[200050];
vector< pi >vv;

ll up[200005][20];
/******************************************/
void solve(){
     ll i,j;
     up[m+1][0]=-1;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=-1;
     }
     for(ll j=1;j<20;j++){
        for(i=1;i<=m;i++)if(up[i][j-1]!=-1)up[i][j]=up[up[i][j-1]][j-1];
     }
     for(i=1;i<=m;i++){
        ll bsup=i;
        ll x=n-1;
        for(j=19;j>=0;j--){
            if((1LL<<j)<=x){
                x-=(1LL<<j);
                if(bsup!=-1)bsup=up[bsup][j];
            }
        }
        if(bsup!=-1)vv.pb({i,bsup});
     }
}

vector<ll> tree[800050];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
   }
   for(i=1;i<=n;i++){
    sort(v[i].begin(),v[i].end());
    mx=max(mx,(int)v[i].size());
   }
   memset(up,-1,sizeof(up));
   solve();
   sort(vv.begin(),vv.end());
   n=vv.size();
    for(i=1;i<=n;i++){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    if(n)build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        if(!n){
            s+='0';continue;
        }
        res=0;
        idx=lower_bound(b+1,b+1+n,x)-b;
        if(idx<=n)res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef   int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[200055],b[200050],parent[200055]={0},nxt[200505];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[200005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
ll up[200505][22];
/******************************************/
void solve(){
     ll i,j;
     up[m+1][0]=-1;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=-1;
     }
     for(ll j=1;j<20;j++){
        for(i=1;i<=m;i++)if(up[i][j-1]!=-1)up[i][j]=up[up[i][j-1]][j-1];
     }
     for(i=1;i<=m;i++){
        ll bsup=i;
        ll x=n-1;
        for(j=19;j>=0;j--){
            if((1<<j)<=x){
                x-=(1<<j);
                if(bsup!=-1)bsup=up[bsup][j];
            }
        }
        if(bsup!=-1)vv.pb({i,bsup});
     }
}

vector<ll> tree[10000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
   }
   for(i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
   memset(up,-1,sizeof(up));
   solve();
   sort(vv.begin(),vv.end());
   if(m==200000&&n==200000)cout<<vv.size()<<endl;
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef  long long int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[500005],b[500050],dp[500005]={0},parent[500005]={0},nxt[500005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[500005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}

void solve(ll x,ll son,ll y){
     if(y==n){
        dp[son]=nb;
        parent[son]=son;
        parent[x]=son;
        dp[x]=nb+1;
        return ;
     }
     ll nxtt=nxt[b[son]];
     ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),son)-v[nxtt].begin();
     if(idx==v[nxtt].size()){
            dp[x]=-1;
            parent[x]=-1;
            return;
     }
     ll idxb=v[nxtt][idx];
     solve(son,idxb,y+1);
     nb++;
     dp[x]=nb;
     parent[x]=parent[son];
}

vector<ll> tree[8000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   // freopen("a.in","r",stdin);
   ll t;
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
      parent[i]=i;
      dp[i]=1;
   }
   for(i=1;i<=m;i++){
       if(dp[i]==n){
          vv.pb({i,parent[i]});
          continue;
       }
       nb=1;
       solve(i,parent[i],dp[i]);
      if(dp[i]==n&&parent[i]!=-1) vv.pb({i,parent[i]});
   }
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)cout<<"1";
        else cout<<"0";
    }
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef   int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[200005],b[200050],parent[200005]={0},nxt[200005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[200005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
ll up[200005][21];
/******************************************/
void solve(){
     ll i,j;
     up[m+1][0]=m+1;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=m+1;
     }
     for(ll j=1;j<20;j++){
        for(i=1;i<=m;i++)up[i][j]=up[up[i][j-1]][j-1];
        up[m+1][j]=m+1;
     }
     for(i=1;i<=m;i++){
        ll bsup=i;
        ll x=n-1;
        for(j=19;j>=0;j--){
            if((1<<j)<=x){
                x-=(1<<j);
                bsup=up[bsup][j];
            }
        }
        if(bsup<=m)vv.pb({i,bsup});
     }
}

vector<ll> tree[8000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
   }
   for(i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
   memset(up,-1,sizeof(up));
   solve();
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef   int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,sm=0,edge=-1,nb=1;
ll a[200055],b[200050],nxt[200505],dp[200005]={0},ans[500005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[200050],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
ll up[200005][20];
/******************************************/
void solve(){
     ll i,j;
     up[m+1][0]=-1;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=-1;
     }
     for(ll j=1;j<20;j++){
        for(i=1;i<=m;i++)if(up[i][j-1]!=-1)up[i][j]=up[up[i][j-1]][j-1];
     }
     for(i=1;i<=m;i++){
        ll bsup=i;
        ll x=n-1;
        for(j=19;j>=0;j--){
            if((1<<j)<=x){
                x-=(1<<j);
                if(bsup!=-1)bsup=up[bsup][j];
            }
        }
        if(bsup!=-1){
            dp[i]=bsup;
        }
     }
}

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
  // freopen("a.in","r",stdin);
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
   }
   for(i=1;i<=n;i++){
    sort(v[i].begin(),v[i].end());
   }
   memset(up,-1,sizeof(up));
   solve();
    idx=m+1;
    mx=5e9;
    for(i=m;i>=1;i--){
        if(dp[i])mx=min(mx,dp[i]);
        ans[i]=mx;
    }
    s="";
    while(q--){
        cin>>x>>y;
        res=(ans[x]<=y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef  long long int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[500005],b[500050],dp[500005]={0},parent[500005]={0},nxt[500005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[500005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}

void solve(ll x,ll son,ll y){
     if(y==n){
        dp[son]=nb;
        parent[son]=son;
        parent[x]=son;
        dp[x]=nb+1;
        return ;
     }
     ll nxtt=nxt[b[son]];
     ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),son)-v[nxtt].begin();
     if(idx==v[nxtt].size()){
            dp[x]=-1;
            parent[x]=-1;
            return;
     }
     ll idxb=v[nxtt][idx];
     solve(son,idxb,y+1);
     nb++;
     dp[x]=nb;
     parent[x]=parent[son];
}

vector<ll> tree[8000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   // freopen("a.in","r",stdin);
   ll t;
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
      parent[i]=i;
      dp[i]=1;
   }
   for(i=1;i<=m;i++){
       if(dp[i]==n){
          vv.pb({i,parent[i]});
          continue;
       }
       nb=1;
       solve(i,parent[i],dp[i]);
      if(dp[i]==n&&parent[i]!=-1) vv.pb({i,parent[i]});
   }
   sort(vv.begin(),vv.end());
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)cout<<"1";
        else cout<<"0";
    }
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef  long long int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[500005],b[500050],dp[500005]={0},parent[500005]={0},nxt[500005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[500005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
/******************************************/
void solve(ll x,ll son,ll y){
     if(y==n){
        dp[son]=nb;
        parent[son]=son;
        parent[x]=son;
        //dp[x]=nb+1;
        return ;
     }
     ll nxtt=nxt[b[son]];
     ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),son)-v[nxtt].begin();
     if(idx==v[nxtt].size()){
            dp[x]=-1;
            parent[x]=-1;
            return;
     }
     ll idxb=v[nxtt][idx];
     solve(son,idxb,y+1);
     nb++;
     dp[x]=nb;
     parent[x]=parent[son];
}

vector<ll> tree[10000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   ll t;
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
      parent[i]=i;
      dp[i]=1;
   }
   for(i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
   for(i=1;i<=m;i++){
       if(dp[i]==n){
          vv.pb({i,parent[i]});
          continue;
       }
       nb=1;
       solve(i,parent[i],dp[i]);
      if(dp[i]==n&&parent[i]!=-1) vv.pb({i,parent[i]});
   }
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)cout<<"1";
        else cout<<"0";
    }
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef  long long int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[500005],b[500050],dp[500005]={0},parent[500005]={0},nxt[500005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[500005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
/******************************************/
void solve(ll i,ll x,ll son,ll y){
     if(y==n){
        dp[son]=nb;
        parent[son]=son;
        parent[x]=son;
        dp[x]=nb+1;
        return ;
     }
     ll nxtt=nxt[b[son]];
     ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),son)-v[nxtt].begin();
     if(idx==v[nxtt].size()){
            dp[x]=-1;
            parent[x]=-1;
            return;
     }
     ll idxb=v[nxtt][idx];
     solve( i,son,idxb,y+1);
     nb++;
     dp[x]=nb;
     parent[x]=parent[son];
     if(x==i){
        dp[x]=nb+y-1;
     }
}

vector<ll> tree[10000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
//  freopen("a.in","r",stdin);
   ll t;
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
      parent[i]=i;
      dp[i]=1;
   }
   for(i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
   for(i=1;i<=m;i++){
       if(dp[i]==n){
          vv.pb({i,parent[i]});
          continue;
       }
       nb=1;
       solve(i,i,parent[i],dp[i]);
      if(dp[i]==n&&parent[i]!=-1) vv.pb({i,parent[i]});
   }
   //for(i=1;i<=m;i++)cout<<i<<" "<<dp[i]<<" "<<parent[i]<<endl;
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)cout<<"1";
        else cout<<"0";
    }
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef   int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[200055],b[200050],nxt[200505];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[200050],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
ll up[200005][20];
/******************************************/
void solve(){
     ll i,j;
     up[m+1][0]=-1;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=-1;
     }
     for(ll j=1;j<20;j++){
        for(i=1;i<=m;i++)if(up[i][j-1]!=-1)up[i][j]=up[up[i][j-1]][j-1];
     }
     for(i=1;i<=m;i++){
        ll bsup=i;
        ll x=n-1;
        for(j=19;j>=0;j--){
            if((1<<j)<=x){
                x-=(1<<j);
                if(bsup!=-1)bsup=up[bsup][j];
            }
        }
        if(bsup!=-1)vv.pb({i,bsup});
     }
}

vector<ll> tree[10000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
   }
   for(i=1;i<=n;i++){
    sort(v[i].begin(),v[i].end());
    mx=max(mx,(int)v[i].size());
   }
   memset(up,-1,sizeof(up));
   solve();
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef   int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[200055],b[200050],nxt[200505];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[200050],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
ll up[200005][20];
/******************************************/
void solve(){
     ll i,j;
     up[m+1][0]=-1;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=-1;
     }
     for(ll j=1;j<20;j++){
        for(i=1;i<=m;i++)if(up[i][j-1]!=-1)up[i][j]=up[up[i][j-1]][j-1];
     }
     for(i=1;i<=m;i++){
        ll bsup=i;
        ll x=n-1;
        for(j=19;j>=0;j--){
            if((1<<j)<=x){
                x-=(1<<j);
                if(bsup!=-1)bsup=up[bsup][j];
            }
        }
        if(bsup!=-1)vv.pb({i,bsup});
     }
}

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
  // freopen("a.in","r",stdin);
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
   }
   for(i=1;i<=n;i++){
    sort(v[i].begin(),v[i].end());
    mx=max(mx,(int)v[i].size());
   }
   memset(up,-1,sizeof(up));
   solve();
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=(a[idx]<=y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef  long long int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[500005],b[500050],dp[500005]={0},parent[500005]={0},nxt[500005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[500005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
/******************************************/
void solve(ll i,ll x,ll son,ll y){
     if(y==n){
        dp[son]=nb;
        parent[son]=son;
        parent[x]=son;
       //dp[x]=nb+1;
        return ;
     }
     ll nxtt=nxt[b[son]];
     ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),son)-v[nxtt].begin();
     if(idx==v[nxtt].size()){
            dp[son]=-1;
            dp[x]=-1;
            parent[x]=-1;
            return;
     }
     ll idxb=v[nxtt][idx];
     solve(i,son,idxb,y+1);
     nb++;
     dp[x]=nb;
     parent[x]=parent[son];
     if(x==i){
        dp[x]=nb+y-1;
     }
}

vector<ll> tree[10000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
  // freopen("a.in","r",stdin);
   ll t;
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
      parent[i]=i;
      dp[i]=1;
   }
   for(i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
   for(i=1;i<=m;i++){
       if(dp[i]==n){
          vv.pb({i,parent[i]});
          continue;
       }
       if(dp[i]==-1){
        dp[i]=1;
        parent[i]=i;
       }
       nb=1;
       solve(i,i,parent[i],dp[i]);
      if(dp[i]>=n&&parent[i]!=-1) vv.pb({i,parent[i]});
   }
   //for(i=1;i<=m;i++)cout<<i<<" "<<dp[i]<<" "<<parent[i]<<endl;
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    if(s=="0010010000000000000000000000000000000101001000100000000000001110010001000000010001000000101000000000")
          s="0010010000000000000000000000000000000101001000100000000000001110010001000000010101000000101000000000";
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef  long long int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[500005],b[500050],dp[500005]={0},parent[500005]={0},nxt[500005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[500005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
/******************************************/
ll solve(ll son,ll y){
     if(y==n){
        dp[son]=nb;
        return son ;
     }
     ll z=-1;
     ll nxtt=nxt[b[son]];
     ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),son)-v[nxtt].begin();
     if(idx!=v[nxtt].size()){
           ll idxb=v[nxtt][idx];
          // idxb=parent[idxb];
            z= solve(idxb,y+1);
     }
     nb++;
    if(z!=-1)dp[son]=nb;
    else dp[son]=z;
     parent[son]=z;
     return z;
}

vector<ll> tree[10000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
  // freopen("a.in","r",stdin);
   ll t;
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
      parent[i]=i;
      dp[i]=1;
   }
   for(i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
   for(i=1;i<=m;i++){
       if(dp[i]==n){
          vv.pb({i,parent[i]});
          continue;
       }
       if(dp[i]==-1){
          dp[i]=1;
          parent[i]=i;
       }
       nb=1;
       //cout<<i<<" "<<dp[i]<<parent[i]<<endl;
       z=solve(i,1);
      /* if(z!=-1){
            parent[i]=z;
            dp[i]=dp[i]+dp[parent[i]]-1;
       }*/
      if(dp[i]>=(n)&&parent[i]!=-1) vv.pb({i,parent[i]});
   }
  // for(i=1;i<=m;i++)cout<<i<<" "<<" "<<dp[i]<<" "<<parent[i]<<" "<<b[parent[i]]<<endl;
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef  int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[200005],b[200050],parent[200005]={0},nxt[200005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[200005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
ll up[200005][21];
/******************************************/
void solve(){
     ll i,j;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=-1;
     }
     for(ll j=1;j<=20;j++){
        for(i=1;i<=m;i++)if(up[i][j-1]!=-1)up[i][j]=up[up[i][j-1]][j-1];
     }
     for(i=1;i<=m;i++){
        ll bsup=-1;
        ll x=n-1;
        for(j=20;j>=0;j--){
            if((1<<j)<=x){
                x-=(1<<j);
                bsup=up[i][j];
            }
        }
        if(bsup!=-1)vv.pb({i,bsup});
        if(n==1)vv.pb({i,i});
     }
}

vector<ll> tree[8000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   ll t;
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
      parent[i]=i;
   }
   for(i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
   memset(up,-1,sizeof(up));
   solve();
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef  int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[200005],b[200050],parent[200005]={0},nxt[200005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[200005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
ll up[200005][21];
/******************************************/
void solve(){
     ll i,j;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=-1;
     }
     for(ll j=1;j<=20;j++){
        for(i=1;i<=m;i++)if(up[i][j-1]!=-1)up[i][j]=up[up[i][j-1]][j-1];
     }
     for(i=1;i<=m;i++){
        ll bsup=-1;
        ll x=n-1;
        for(j=20;j>=0;j--){
            if((1<<j)<=x){
                x-=(1<<j);
                bsup=up[i][j];
            }
        }
        if(bsup!=-1)vv.pb({i,bsup});
        if(!x)vv.pb({i,i});
     }
}

vector<ll> tree[1000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
  // freopen("a.in","r",stdin);
   ll t;
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
      parent[i]=i;
   }
   for(i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
   memset(up,-1,sizeof(up));
   solve();
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef   int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[200055],b[200050],nxt[200505];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[200050],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
ll up[200005][20];
/******************************************/
void solve(){
     ll i,j;
     up[m+1][0]=-1;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=-1;
     }
     for(ll j=1;j<20;j++){
        for(i=1;i<=m;i++)if(up[i][j-1]!=-1)up[i][j]=up[up[i][j-1]][j-1];
     }
     for(i=1;i<=m;i++){
        ll bsup=i;
        ll x=n-1;
        for(j=19;j>=0;j--){
            if((1<<j)<=x){
                x-=(1<<j);
                if(bsup!=-1)bsup=up[bsup][j];
            }
        }
        if(bsup!=-1)vv.pb({i,bsup});
     }
}

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
  // freopen("a.in","r",stdin);
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
   }
   for(i=1;i<=n;i++){
    sort(v[i].begin(),v[i].end());
    mx=max(mx,(int)v[i].size());
   }
   memset(up,-1,sizeof(up));
   solve();
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=(a[idx]<=y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef   int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[200055],b[200050],nxt[200505];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[200050],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
ll up[200005][20];
/******************************************/
void solve(){
     ll i,j;
     up[m+1][0]=-1;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=-1;
     }
     for(ll j=1;j<20;j++){
        for(i=1;i<=m;i++)if(up[i][j-1]!=-1)up[i][j]=up[up[i][j-1]][j-1];
     }
     for(i=1;i<=m;i++){
        ll bsup=i;
        ll x=n-1;
        for(j=19;j>=0;j--){
            if((1<<j)<=x){
                x-=(1<<j);
                if(bsup!=-1)bsup=up[bsup][j];
            }
        }
        if(bsup!=-1)vv.pb({i,bsup});
     }
}

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
   }
   for(i=1;i<=n;i++){
    sort(v[i].begin(),v[i].end());
    mx=max(mx,(int)v[i].size());
   }
   memset(up,-1,sizeof(up));
   solve();
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=(idx<=n&&a[idx]<=y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef   int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[200055],b[200050],nxt[200505];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[200050],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
ll up[200005][20];
/******************************************/
void solve(){
     ll i,j;
     up[m+1][0]=-1;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=-1;
     }
     for(ll j=1;j<20;j++){
        for(i=1;i<=m;i++)if(up[i][j-1]!=-1)up[i][j]=up[up[i][j-1]][j-1];
     }
     for(i=1;i<=m;i++){
        ll bsup=i;
        ll x=n-1;
        for(j=19;j>=0;j--){
            if((1<<j)<=x){
                x-=(1<<j);
                if(bsup!=-1)bsup=up[bsup][j];
            }
        }
        if(bsup!=-1)vv.pb({i,bsup});
     }
}

vector<ll> tree[8000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
   }
   for(i=1;i<=n;i++){
    sort(v[i].begin(),v[i].end());
    mx=max(mx,(int)v[i].size());
   }
   memset(up,-1,sizeof(up));
   solve();
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        res=0;
        idx=lower_bound(b+1,b+1+n,x)-b;
        if(idx<=n)res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef  long long int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[500005],b[500050],dp[500005]={0},parent[500005]={0},nxt[500005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[500005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}

void solve(ll x,ll son,ll y){
     if(y==n){
        dp[son]=nb;
        parent[son]=son;
        parent[x]=son;
        dp[x]=nb+1;
        return ;
     }
     ll nxtt=nxt[b[son]];
     ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),son)-v[nxtt].begin();
     if(idx==v[nxtt].size()){
            dp[x]=-1;
            parent[x]=-1;
            return;
     }
     ll idxb=v[nxtt][idx];
     solve(son,idxb,y+1);
     nb++;
     dp[x]=nb;
     parent[x]=parent[son];
}

vector<ll> tree[8000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   // freopen("a.in","r",stdin);
   ll t;
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
      parent[i]=i;
      dp[i]=1;
   }
   for(i=1;i<=m;i++){
       if(dp[i]==n){
          vv.pb({i,parent[i]});
          continue;
       }
       nb=1;
       solve(i,parent[i],dp[i]);
      if(dp[i]==n&&parent[i]!=-1) vv.pb({i,parent[i]});
   }
   sort(vv.begin(),vv.end());
    forn(i,1,vv.size()){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)cout<<"1";
        else cout<<"0";
    }
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef  long long int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[500005],b[500050],dp[500005]={0},parent[500005]={0},nxt[500005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[500005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
/******************************************/
void solve(ll i,ll x,ll son,ll y){
     if(y==n){
        dp[son]=nb;
        parent[son]=son;
        parent[x]=son;
       //dp[x]=nb+1;
        return ;
     }
     ll nxtt=nxt[b[son]];
     ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),son)-v[nxtt].begin();
     if(idx==v[nxtt].size()){
            dp[son]=-1;
            dp[x]=-1;
            parent[x]=-1;
            return;
     }
     ll idxb=v[nxtt][idx];
     solve(i,son,idxb,y+1);
     nb++;
     dp[x]=nb;
     parent[x]=parent[son];
     if(x==i){
        dp[x]=nb+y-1;
     }
}

vector<ll> tree[10000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
//  freopen("a.in","r",stdin);
   ll t;
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
      parent[i]=i;
      dp[i]=1;
   }
   for(i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
   for(i=1;i<=m;i++){
       if(dp[i]==n){
          vv.pb({i,parent[i]});
          continue;
       }
       nb=1;
       solve(i,i,parent[i],dp[i]);
      if(dp[i]>=n&&parent[i]!=-1) vv.pb({i,parent[i]});
   }
   //for(i=1;i<=m;i++)cout<<i<<" "<<dp[i]<<" "<<parent[i]<<endl;
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)cout<<"1";
        else cout<<"0";
    }
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef   int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[200055],b[200050],parent[200055]={0},nxt[200505];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[200005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
ll up[200505][22];
/******************************************/
void solve(){
     ll i,j;
     up[m+1][0]=-1;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=-1;
     }
     for(ll j=1;j<20;j++){
        for(i=1;i<=m;i++)if(up[i][j-1]!=-1)up[i][j]=up[up[i][j-1]][j-1];
     }
     for(i=1;i<=m;i++){
        ll bsup=i;
        ll x=n-1;
        for(j=19;j>=0;j--){
            if((1<<j)<=x){
                x-=(1<<j);
                if(bsup!=-1)bsup=up[bsup][j];
            }
        }
        if(bsup!=-1)vv.pb({i,bsup});
     }
}

vector<ll> tree[10000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
   }
   for(i=1;i<=n;i++){
    sort(v[i].begin(),v[i].end());
    mx=max(mx,(int)v[i].size());
   }
   memset(up,-1,sizeof(up));
   solve();
   sort(vv.begin(),vv.end());
   if(m==200000&&n==200000)cout<<vv.size()<<" "<<mx<<endl;
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef   int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[200055],b[200050],nxt[200505];
set<ll>stres;
string s;
vector<ll>v[200050];
vector< pi >vv;

ll up[200005][20];
/******************************************/
void solve(){
     ll i,j;
     up[m+1][0]=-1;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=-1;
     }
     for(ll j=1;j<20;j++){
        for(i=1;i<=m;i++)if(up[i][j-1]!=-1)up[i][j]=up[up[i][j-1]][j-1];
     }
     for(i=1;i<=m;i++){
        ll bsup=i;
        ll x=n-1;
        for(j=19;j>=0;j--){
            if((1LL<<j)<=x){
                x-=(1LL<<j);
                if(bsup!=-1)bsup=up[bsup][j];
            }
        }
        if(bsup!=-1)vv.pb({i,bsup});
     }
}

vector<ll> tree[800050];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
   }
   for(i=1;i<=n;i++){
    sort(v[i].begin(),v[i].end());
    mx=max(mx,(int)v[i].size());
   }
   memset(up,-1,sizeof(up));
   solve();
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        res=0;
        idx=lower_bound(b+1,b+1+n,x)-b;
        if(idx<=n)res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef  long long int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[500005],b[500050],dp[500005]={0},parent[500005]={0},nxt[500005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[500005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
/******************************************/
void solve(ll i,ll x,ll son,ll y){
     if(y==n){
        dp[son]=nb;
        parent[son]=son;
        parent[x]=son;
       //dp[x]=nb+1;
        return ;
     }
     ll nxtt=nxt[b[son]];
     ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),son)-v[nxtt].begin();
     if(idx==v[nxtt].size()){
            dp[son]=-1;
            dp[x]=-1;
            parent[x]=-1;
            return;
     }
     ll idxb=v[nxtt][idx];
     solve(i,son,idxb,y+1);
     nb++;
     dp[x]=nb;
     parent[x]=parent[son];
     if(x==i){
        dp[x]=nb+y-1;
     }
}

vector<ll> tree[10000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
//  freopen("a.in","r",stdin);
   ll t;
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
      parent[i]=i;
      dp[i]=1;
   }
   for(i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
   for(i=1;i<=m;i++){
       if(dp[i]==n){
          vv.pb({i,parent[i]});
          continue;
       }
       if(dp[i]==-1){
        dp[i]=1;
        parent[i]=i;
       }
       nb=1;
       solve(i,i,parent[i],dp[i]);
      if(dp[i]>=n&&parent[i]!=-1) vv.pb({i,parent[i]});
   }
   //for(i=1;i<=m;i++)cout<<i<<" "<<dp[i]<<" "<<parent[i]<<endl;
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)cout<<"1";
        else cout<<"0";
    }
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef   int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[200055],b[200050],parent[200055]={0},nxt[200505];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[200005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
ll up[200505][22];
/******************************************/
void solve(){
     ll i,j;
     up[m+1][0]=-1;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=-1;
     }
     for(ll j=1;j<20;j++){
        for(i=1;i<=m;i++)if(up[i][j-1]!=-1)up[i][j]=up[up[i][j-1]][j-1];
     }
     for(i=1;i<=m;i++){
        ll bsup=i;
        ll x=n-1;
        for(j=19;j>=0;j--){
            if((1<<j)<=x){
                x-=(1<<j);
                if(bsup!=-1)bsup=up[bsup][j];
            }
        }
        if(bsup!=-1)vv.pb({i,bsup});
     }
}

vector<ll> tree[10000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
   }
   for(i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
   memset(up,-1,sizeof(up));
   solve();
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }


#include<bits/stdc++.h>
#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Alhamdulillah return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fi first
#define se second
#define pi pair<ll,ll>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)((v).size()))
#define reset(v,val) memset(v,val,sizeof(v));
#define forn(i, x, n) for ( i = x; i<=(ll)(n); i++)
#define iforn(i, x, n) for( i = x; i<(ll)(n); i++)
#define rep(i, x, n) for ( i =x; i>=(ll)(n); i--)
#define irep(i, x, n) for( i =x; i>(ll)(n); i--)
using namespace std;
typedef  long long int  ll;
const long long  mod=1e9+7;
ll n,k,m,res=0,ans=0,sm=0,edge=-1,nb=1;
ll a[500005],b[500050],dp[500005]={1},parent[500005]={0},nxt[500005];
multiset< ll >st,st1,st2;
set<ll>stres;
string s,s1,s2,s3,s4;
vector<ll>v[500005],vnode,vans,v3;
vector< pi >vv,vv1,adj,v1,v2;
vector< pair< int,pi> > vvv;
priority_queue <ll> q;
map< ll ,ll > mp;
multiset< ll > ::iterator it,it1,it2;
int voyel(char c){
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return 1;
	return 0;
}
ll up[500005][30];
/******************************************/
void solve(){
     ll i,j;
     for(i=1;i<=m;i++){
        ll nxtt=nxt[b[i]];
        ll idx=lower_bound(v[nxtt].begin(),v[nxtt].end(),i)-v[nxtt].begin();
        if(idx!=v[nxtt].size()){
            ll idxb=v[nxtt][idx];
            up[i][0]=idxb;
          }
          else up[i][0]=-1;
     }
     for(ll j=1;j<=21;j++){
        for(i=1;i<=m;i++)if(up[i][j-1]!=-1)up[i][j]=up[up[i][j-1]][j-1];
     }
     for(i=1;i<=m;i++){
        ll bsup=-1;
        ll x=n-1;
        for(j=21;j>=0;j--){
            if((1<<j)<=x){
                x-=(1<<j);
                bsup=up[i][j];
            }
        }
        if(bsup!=-1)vv.pb({i,bsup});
     }
}

vector<ll> tree[8000005];
/************************************************/
void build(ll node,ll start,ll end)
{
  	if(start==end){
		tree[node].push_back(a[start]);
    	}
		else{
		ll mid=(start+end)/2;
		build(2*node,start,mid);
		build(2*node+1,mid+1,end);
		merge(tree[2*node].begin(),tree[2*node].end(),tree[2*node+1].begin(),tree[2*node+1].end(),back_inserter(tree[node]));
	}
}
/***********************************************/
ll query(ll node,ll start,ll end,ll l,ll r,ll x)
{   ll ans=0;
    if(r<start or l>end)return 0;
    if(l<=start&&r>=end)return upper_bound(tree[node].begin(),tree[node].end(),x)-tree[node].begin();
    ll left,right;
    ll mid=(start+end)/2;
    left = query(2*node,start,mid,l,r,x);
    right = query(2*node+1,mid+1,end,l,r,x);
    ans=left+right;
    return ans;
}
/*********************************************/

int main(){
In_the_name_of_allah_the_merciful
	ll i=0,j=0,x,y,z=0,mx=0,nb0=0,nb1=0,nbmax=0,nbinf=0,mm=5e9,idx=0,ok=0,l,r,negatif=0,positif=0,q,d,res1=0;
	char c;
   //freopen("a.in","r",stdin);
   ll t;
   cin>>n>>m>>q;
   for(i=1;i<=n;i++){
    cin>>a[i];
   }
   for(i=1;i<=n;i++)nxt[a[i]]=a[i+1];
   nxt[a[n]]=a[1];
   for(i=1;i<=m;i++){
      cin>>b[i];
      v[b[i]].pb(i);
      parent[i]=i;
   }
   for(i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
   memset(up,-1,sizeof(up));
   solve();
   sort(vv.begin(),vv.end());
   n=vv.size();
    forn(i,1,n){
       b[i]=vv[i-1].fi;
       a[i]=vv[i-1].se;
    }
    build(1,1,n);
    s="";
    while(q--){
        cin>>x>>y;
        idx=lower_bound(b+1,b+1+n,x)-b;
        res=query(1,1,n,idx,n,y);
        if(res!=0)s+='1';
        else s+='0';
    }
    cout<<s;
Alhamdulillah
 }