#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, c1, c2;
  scanf("%d %d", &n, &m);
  c1 = c2 = 0;
  for (int i = 0; i < n; i++) {
    int k;
    scanf("%d", &k);
    if (k == 1)
      c1++;
    else
      c2++;
  }
  for (int i = 0; i < m; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    if ((r - l) % 2 == 0)
      printf("0\n");
    else if ((r - l + 1) / 2 > min(c1, c2))
      printf("0\n");
    else
      printf("1\n");
  }
  return 0;
}
