#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x;
  int l, r, c;
  map<int, int> num;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    num[x]++;
  }
  while (m--) {
    scanf("%d %d", &l, &r);
    c = r - l + 1;
    if (c % 2 != 0) {
      printf("0\n");
    } else {
      if (num[1] >= c / 2 && num[-1] >= c / 2) {
        printf("1\n");
      } else {
        printf("0\n");
      }
    }
  }
  return 0;
}
