#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, m;
  cin >> n >> m;
  long long arr[n];
  long long neg = 0, pos = 0;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] == -1) {
      neg++;
    } else {
      pos++;
    }
  }
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    long long check = y - x + 1;
    if (check % 2 == 0) {
      if (neg >= check / 2 && pos >= check / 2) {
        cout << 1 << "\n";
      } else
        cout << 0 << "\n";
    } else
      cout << 0 << "\n";
  }
  return 0;
}
