#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     int m;     cin >> n >> m;     int l;     int r;     int arr[n];     int pos = 0;     int neg = 0;     for (int i = 0; i < n; i++) {       cin >> arr[i];       if (arr[i] == -1) {         neg++;       } else {         pos++;       }     }     int mn = min(neg, pos);     for (int i = 0; i < m; i++) {       cin >> l >> r;       int c = 0;       if (l == r) {         cout <<  0  << endl;         c++;       }       if (c == 0) {         if ((abs(l - r) + 1) / 2 <= mn && (abs(l - r) + 1) % 2 == 0) {           cout <<  1  << endl;         } else {           cout <<  0  << endl;         }       }     }     return 0;   }   