#include <bits/stdc++.h>
int n, m, a, b;
int main() {
  int tm;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &tm);
    if (tm == 1)
      a++;
    else
      b++;
  }
  int l, r;
  while (m--) {
    scanf("%d%d", &l, &r);
    if ((r - l + 1) % 2 == 0 && (r - l + 1) / 2 <= a && (r - l + 1) / 2 <= b)
      puts("1");
    else
      puts("0");
  }
  return 0;
}
