#include <bits/stdc++.h>
int intcmp(const void *f, const void *s) { return (*(int *)f - *(int *)s); }
int gcd(int a, int b) { return ((b == 0) ? a : gcd(b, a % b)); }
int preprocess() { return 0; }
int main() {
  int cases;
  int i, j, n;
  int a, m;
  preprocess();
  scanf("%d", &n);
  scanf("%d", &m);
  int ones = 0, minus = 0;
  for (i = 0; i < n; ++i) {
    scanf("%d", &a);
    if (a == 1)
      ones++;
    else
      minus++;
  }
  while (m--) {
    int l, r, cnt;
    scanf("%d%d", &l, &r);
    cnt = r - l + 1;
    if (cnt & 1) {
      printf("0\n");
      continue;
    }
    int left = cnt / 2;
    if ((left <= ones) && (left <= minus)) {
      printf("1\n");
      continue;
    } else {
      printf("0\n");
      continue;
    }
  }
  return 0;
}
