#include <bits/stdc++.h>
using namespace std;
int ar[200010] = {0};
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int numz = 0;
  int numf = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &ar[i]);
    if (ar[i] == 1)
      numz++;
    else
      numf++;
  }
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    int mid = (b - a + 1) / 2;
    if (b - a == 0 || (b - a) % 2 == 0)
      printf("0\n");
    else {
      if ((numz >= mid) && (numf >= mid))
        printf("1\n");
      else
        printf("0\n");
    }
  }
  return 0;
}
