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