#include <bits/stdc++.h>
using namespace std;
int a[200001], T[4 * 200001];
int main() {
  int n, m;
  int unos = 0, nu = 0;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    if (a[i] == 1)
      unos++;
    else
      nu++;
  }
  int l, r;
  while (m--) {
    scanf("%d %d", &l, &r);
    if ((r - l + 1) & 1) {
      printf("0\n");
      continue;
    } else {
      int temp = r - l + 1;
      if (unos >= temp / 2 and nu >= temp / 2)
        printf("1\n");
      else
        printf("0\n");
    }
  }
  return 0;
}
