#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, m;
  long aplus = 0, aminus = 0;
  int temp;
  long i, j;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> temp;
    if (temp == 1) {
      aplus++;
    }
    if (temp == -1) {
      aminus++;
    }
  }
  long l, r;
  for (i = 0; i < m; i++) {
    cin >> l >> r;
    j = r - l + 1;
    if ((j % 2 == 0) && ((j / 2) <= aminus) && ((j / 2) <= aplus)) {
      cout << "1\n";
    } else {
      cout << "0\n";
    }
  }
  return 0;
}
