#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, a, neg = 0, pos = 0, b, dif;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a < 0) neg++;
  }
  pos = n - neg;
  pos *= 2;
  neg *= 2;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    dif = b - a;
    if (!(dif % 2) || pos < dif || neg < dif)
      cout << "0\n";
    else
      cout << "1\n";
  }
  return 0;
}
