#include <bits/stdc++.h>
using namespace std;
int min(int arr[]) {
  int minimum = INT_MAX;
  for (int i = 0; i < 30; i++) {
    if (minimum > arr[i]) minimum = arr[i];
  }
  return minimum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long n, m;
  cin >> n >> m;
  long a[n], c = 0;
  for (long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == -1) c++;
  }
  while (m--) {
    long l, r;
    cin >> l >> r;
    if ((r - l + 1) % 2 != 0)
      cout << "0" << endl;
    else {
      if (c >= (r - l + 1) / 2 && (n - c) >= (r - l + 1) / 2)
        cout << "1" << endl;
      else
        cout << "0" << endl;
    }
  }
  return 0;
}
