#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int fr[4], n, q;
int main() {
  scanf("%d", &n);
  scanf("%d", &q);
  for (long long i = 1; i <= n; i++) {
    int tmp;
    scanf("%d", &tmp);
    fr[tmp + 1]++;
  }
  while (q--) {
    int l, r;
    scanf("%d", &l);
    scanf("%d", &r);
    printf(((r - l + 1) % 2 == 0 && fr[0] >= (r - l + 1) / 2 &&
            fr[2] >= (r - l + 1) / 2)
               ? "1\n"
               : "0\n");
  }
}
