#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b, i, j, t, p = 0, q = 0;
  int x[200001];
  cin >> n >> m;
  for (i = 1; i <= n; ++i) {
    cin >> t;
    if (t == -1)
      p++;
    else
      q++;
  }
  for (i = 0; i < m; ++i) {
    cin >> a >> b;
    if ((b - a + 1) % 2 == 0 && (b - a + 1) / 2 <= p && (b - a + 1) / 2 <= q)
      cout << 1 << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}
