#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int minusone = 0;
  int one = 0;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    if (a == -1) {
      minusone++;
    } else {
      one++;
    }
  }
  for (int i = 0; i < m; i++) {
    int ans;
    int queries0, queries1;
    scanf("%d%d", &queries0, &queries1);
    int diff = queries1 - queries0;
    if (diff % 2 == 0) {
      ans = 0;
    } else {
      if (minusone >= diff / 2 + 1 && one >= diff / 2 + 1) {
        ans = 1;
      } else {
        ans = 0;
      }
    }
    printf("%d \n", ans);
  }
}
