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