#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int d, e = 0, a[n], b, c;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 1) e++;
  }
  d = n - e;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &c, &b);
    int p = (b - c + 1);
    if (p % 2 == 0 && e >= p / 2 && d >= p / 2)
      cout << "1" << endl;
    else
      cout << "0" << endl;
  }
}
