#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  long long count1 = 0;
  long long count2 = 0;
  for (long long i = 0; i < n; i++) {
    long long temp;
    cin >> temp;
    if (temp > 0) {
      count2++;
    } else {
      count1++;
    }
  }
  long long pairs = min(count1, count2);
  for (long long i = 0; i < m; i++) {
    long long l, r;
    cin >> l >> r;
    if ((r - l) % 2 != 0) {
      long long check = r - l + 1;
      check = check / 2;
      if (check <= pairs) {
        cout << "1";
      } else {
        cout << "0";
      }
    } else {
      cout << "0";
    }
    cout << "\n";
  }
  return 0;
}
