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