#include <bits/stdc++.h>
using namespace std;
long b[1000000], c[1000000];
int main() {
  long n, m, i, o = 0, mo = 0;
  cin >> n >> m;
  int a[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 1)
      o++;
    else
      mo++;
  }
  long li, ri, ans;
  while (m--) {
    scanf("%ld%ld", &li, &ri);
    ans = ri - li + 1;
    if (ans & 1) {
      printf("0\n");
    } else if ((ans % 2 == 0) && (o >= ans / 2) && (mo >= ans / 2)) {
      printf("1\n");
    } else {
      printf("0\n");
    }
  }
  return 0;
}
