func_code_string: #include <bits/stdc++.h>   using namespace std;   using vi = vector<int>;   const int LOG = 17;   const int inf = 1e9;   template <typename T>   struct RMQ {     vector<vector<T>> spr;     RMQ(const vector<T>& v) : spr(1, v) {       for (int j = 1; (1 << j) <= (int)v.size(); ++j) {         spr.push_back(vector<T>((int)v.size() - (1 << j) + 1));         for (int i = 0; i < (int)spr[j].size(); ++i) {           spr[j][i] = min(spr[j - 1][i], spr[j - 1][i + (1 << (j - 1))]);         }       }     }     T get(int l, int r) {       int d = 31 - __builtin_clz(r - l + 1);       return min(spr[d][l], spr[d][r - (1 << d) + 1]);     }   };   int main() {     cin.tie(0)->sync_with_stdio(0);     int n, m, q;     cin >> n >> m >> q;     vi v(n), g(n);     for (int i = 0; i < n; ++i) cin >> v[i], v[i]--;     for (int i = 0; i < n; ++i) g[v[i]] = v[(i + 1) % n];     vi a(m);     for (int i = 0; i < m; ++i) cin >> a[i], a[i]--;     vector<vi> spr(LOG + 1, vi(m));     vi nxt(n, -1);     for (int i = m - 1; i >= 0; --i) {       nxt[a[i]] = i;       spr[0][i] = nxt[g[a[i]]];     }     for (int j = 0; j < LOG; ++j) {       for (int i = 0; i < m; ++i) {         if (spr[j][i] == -1)           spr[j + 1][i] = -1;         else           spr[j + 1][i] = spr[j][spr[j][i]];       }     }     vi res(m);     for (int i = 0; i < m; ++i) {       int k = i;       for (int j = LOG; j >= 0; --j) {         if ((n - 1) & (1 << j)) {           k = spr[j][k];           if (k == -1) break;         }       }       res[i] = k == -1 ? inf : k;     }     RMQ<int> rmq(res);     string ans;     for (int i = 0; i < q; ++i) {       int l, r;       cin >> l >> r;       --l, --r;       int a = rmq.get(l, r);       if (a <= r)         ans.push_back( 1 );       else         ans.push_back( 0 );     }     cout << ans <<   n ;   }   