#include <bits/stdc++.h>   const long double pi = 3.14159265359;   const long long N = 1e9 + 7;   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, m, arr[200005];     cin >> n >> m;     long long cntne = 0, cntpo = 0;     for (int i = 0; i < n; i++) {       cin >> arr[i];       if (arr[i] == -1)         cntne++;       else         cntpo++;     }     vector<long long> v;     for (int i = 0; i < m; i++) {       long long l, r;       cin >> l >> r;       r++;       long long ans = abs(l - r);       if ((ans % 2 == 0) && (cntne >= ans / 2) && (cntpo >= ans / 2))         v.push_back(1);       else         v.push_back(0);     }     for (int i = 0; i < ((long long)((v).size())); i++) cout << v[i] << endl;     return 0;   }   