#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int m, n, l, r, neg = 0, pos = 0;
  cin >> n >> m;
  int A[n], c = 0, i;
  for (i = 0; i < n; i++) {
    cin >> A[i];
    if (A[i] == -1)
      neg++;
    else
      pos++;
  }
  while (c < m) {
    scanf("%I64d%I64d", &l, &r);
    if ((r - l) % 2 == 0) {
      cout << "0" << endl;
      c++;
      continue;
    } else {
      int k = r - l + 1;
      if (neg >= k / 2 && pos >= k / 2) {
        cout << "1" << endl;
      } else {
        cout << "0" << endl;
      }
      c++;
    }
  }
  return 0;
}
