#include <bits/stdc++.h>
using namespace std;
const double pi = 2 * acos(0);
void start() {}
void solve() {
  long long int n, m, pos = 0, neg = 0;
  cin >> n >> m;
  int a[n + 5];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < 0)
      neg++;
    else
      pos++;
  }
  while (m--) {
    long long int l, r;
    cin >> l >> r;
    long long int len = r - l + 1;
    if (len & 1)
      cout << "0"
           << "\n";
    else {
      len /= 2;
      if (len <= pos && len <= neg)
        cout << "1"
             << "\n";
      else
        cout << "0"
             << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
