#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 256;
int n, a[2 * MAXN], m, nul, one;
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (a[i] == 1)
      one++;
    else
      nul++;
  }
  while (m--) {
    int l, r;
    cin >> l >> r;
    if ((r - l + 1) % 2 == 0 && one >= (r - l + 1) / 2 &&
        nul >= (r - l + 1) / 2)
      cout << 1;
    else
      cout << 0;
    cout << '\n';
  }
  return 0;
}
