#include <bits/stdc++.h>
using namespace std;
int N, Q, l, r, i, a, V[200010];
int main() {
  cin >> N >> Q;
  for (i = 1; i <= N; i++) {
    cin >> a;
    V[i] = V[i - 1];
    if (a == 1) V[i] = V[i] + 1;
  }
  for (; Q; --Q) {
    cin >> l >> r;
    if ((r - l + 1) % 2) {
      cout << 0 << "\n";
      continue;
    }
    if (V[N] >= (r - l + 1) / 2 && N - V[N] >= (r - l + 1) / 2) {
      cout << 1 << "\n";
      continue;
    }
    cout << 0 << "\n";
  }
  return 0;
}
