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