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