#include <bits/stdc++.h>
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int i, l, r, k, plus = 0, minus = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &l);
    if (l == 1)
      plus++;
    else
      minus++;
  }
  for (i = 0; i < m; i++) {
    scanf("%d %d", &l, &r);
    k = r - l + 1;
    if (k % 2 == 0 && plus >= k / 2 && minus >= k / 2)
      printf("1\n");
    else
      printf("0\n");
  }
  return 0;
}
