#include <bits/stdc++.h>
using namespace std;
const int MaxN = 300 * 1000;
int a[MaxN];
int main() {
  int n, m, t, l, r;
  cin >> n >> m;
  int pos = 0, neg = 0;
  for (int i = 0; i < n; ++i) {
    cin >> t;
    if (t == 1) {
      pos++;
    } else {
      neg++;
    }
  }
  for (int i = 0; i < m; ++i) {
    cin >> l >> r;
    int diff = r - l + 1;
    if (diff % 2 == 0 && neg * 2 >= diff && pos * 2 >= diff) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }
  return 0;
}
