#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, l, r, pos = 0, neg = 0, x;
  cin >> n >> m;
  int a[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    if (x == 1) pos++;
  }
  neg = n - pos;
  while (m-- > 0) {
    scanf("%d%d", &l, &r);
    x = r - l + 1;
    if (x % 2 == 0) {
      if (pos >= x / 2) {
        if (neg >= x / 2) {
          printf("1\n");
          continue;
        }
      }
    }
    printf("0\n");
  }
}
