#include <bits/stdc++.h>
using namespace std;
const int Maxn = int(1e5) + 256;
int d[Maxn * 2], n, m, po, ne;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    if (x == -1) {
      ne++;
    } else {
      po++;
    }
  }
  while (m--) {
    int l, r;
    cin >> l >> r;
    int sz = (r - l + 1);
    if (sz % 2 == 1) {
      cout << 0 << "\n";
    } else if (sz / 2 > ne || sz / 2 > po) {
      cout << 0 << "\n";
    } else {
      cout << 1 << "\n";
    }
  }
  return 0;
}
