#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, i, a, cnt1, cnt2, t;
  scanf("%d%d", &n, &q);
  cnt1 = cnt2 = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a);
    if (a == 1)
      cnt2++;
    else
      cnt1++;
  }
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    if ((r - l) % 2) {
      if ((r - l) / 2 < min(cnt1, cnt2))
        printf("1\n");
      else
        printf("0\n");
    } else
      printf("0\n");
  }
  return 0;
}
