#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, o = 0, on = 0, t, l, r;
  scanf("%d %d", &n, &m);
  while (n--) {
    scanf("%d", &t);
    if (t == 1)
      o++;
    else
      on++;
  }
  t = min(o, on) * 2 - 1;
  while (m--) {
    scanf("%d %d", &l, &r);
    printf("%d\n", ((r - l) % 2 == 1 && r - l <= t) ? 1 : 0);
  }
  return 0;
}
