#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, x, y, count = 0, mini, pos, neg, d;
  cin >> n >> m;
  int a;
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a == 1) {
      count++;
    }
  }
  pos = count;
  neg = n - count;
  mini = 2 * min(pos, neg);
  for (i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    d = (y - x + 1);
    if (d % 2 == 0 && d <= mini) {
      printf("1\n");
    } else
      printf("0\n");
  }
  return 0;
}
