#include <bits/stdc++.h>   using namespace std;   int n, m, q;   int p[200001];   int a[200001];   vector<int> cur[200001];   int pos[200001];   int par[200001][21];   struct cmp {     bool operator()(pair<int, int> a, pair<int, int> b) {       return a.second > b.second;     }   };   priority_queue<pair<int, int>, vector<pair<int, int> >, cmp> h;   struct Q {     int l, r, id;   };   vector<Q> Query;   bool cmp(Q a, Q b) { return a.l < b.l; }   int ans[200001];   int Process(int pos) {     int k = n - 1;     for (int i = 20; i >= 0; i--) {       if (k & (1 << i)) {         if (par[pos][i] == -1) return -1;         pos = par[pos][i];       }     }     return pos;   }   int main() {     cin >> n >> m >> q;     for (int i = 1; i <= n; i++) {       cin >> p[i];       pos[p[i]] = i;     }     for (int i = 1; i <= m; i++) {       cin >> a[i];     }     memset(par, -1, sizeof par);     for (int i = 1; i <= m; i++) {       int x = pos[a[i]];       int y;       if (x == 1)         y = p[n];       else         y = p[x - 1];       for (auto k : cur[y]) {         par[k][0] = i;       }       cur[y].clear();       cur[a[i]].push_back(i);     }     for (int j = 1; j <= 20; j++) {       for (int i = 1; i <= m; i++) {         if (par[i][j - 1] != -1) par[i][j] = par[par[i][j - 1]][j - 1];       }     }     for (int i = 1; i <= q; i++) {       int l, r;       cin >> l >> r;       Query.push_back({l, r, i});     }     sort(Query.begin(), Query.end(), cmp);     for (int i = 1; i <= m; i++) {       int r = Process(i);       if (r != -1) h.push({i, r});     }     for (auto x : Query) {       int id = x.id;       while (!h.empty() && h.top().first < x.l) h.pop();       if (h.empty() || h.top().second > x.r)         ans[id] = 0;       else         ans[id] = 1;     }     for (int i = 1; i <= q; i++) cout << ans[i];     return 0;   }   