#include <bits/stdc++.h>
int main() {
  int n, m, cnta = 0, cntb = 0, tmp, l, r;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &tmp);
    if (tmp == -1)
      ++cnta;
    else
      ++cntb;
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &l, &r);
    tmp = r - l + 1;
    puts((tmp % 2) == 0 && (tmp / 2 <= cnta) && (tmp / 2 <= cntb) ? "1" : "0");
  }
  return 0;
}
