#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  scanf("%lld %lld", &n, &m);
  long long a, c1 = 0, c2 = 0;
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &a);
    if (a == 1)
      c1++;
    else
      c2++;
  }
  long long x = min(c1, c2);
  while (m--) {
    long long l, r;
    scanf("%lld %lld", &l, &r);
    long long y = r - l + 1;
    if (y % 2 == 0 && x >= y / 2)
      printf("1\n");
    else
      printf("0\n");
  }
}
