#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, m;
  cin >> n >> m;
  long int a[n + 3];
  for (long int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long int l, r, one = 0, negone = 0;
  for (long int i = 1; i <= n; i++) {
    if (a[i] == 1)
      one++;
    else
      negone++;
  }
  for (long int i = 0; i < m; i++) {
    cin >> l >> r;
    long int count = (r - l) + 1;
    bool flag = 1;
    if (count % 2 == 0) {
      if (one < count / 2 || negone < count / 2) flag = 0;
    } else {
      flag = 0;
    }
    if (flag)
      cout << "1" << endl;
    else
      cout << "0" << endl;
  }
  return 0;
}
