#include <bits/stdc++.h>
using namespace std;
int code() {
  long long n, m;
  cin >> n >> m;
  int ar[n];
  long long countn = 0, countp = 0;
  for (long long i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x < 0)
      countn++;
    else
      countp++;
  }
  while ((m--)) {
    long long n1, n2;
    cin >> n1 >> n2;
    long long ran = n2 - n1 + 1;
    if (ran % 2)
      cout << "0";
    else {
      if ((countn >= ran / 2) && (countp >= (ran / 2)))
        cout << "1";
      else
        cout << "0";
    }
    cout << "\n";
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) code();
  return 0;
}
