#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, v, i, flag = 0, n1, n2;
  scanf("%d%d", &n, &m);
  int c1 = 0, c2 = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &v);
    if (v % 2 == 1) {
      c2++;
    } else {
      c1++;
    }
    v = 0;
  }
  for (i = 0; i < m; i++) {
    scanf("%d%d", &n1, &n2);
    n = n2 - n1 + 1;
    if (n % 2 == 1) {
      cout << "0"
           << "\n";
    } else if (n % 2 == 0 and n <= 2 * min(c1, c2)) {
      cout << "1"
           << "\n";
    } else {
      cout << "0"
           << "\n";
    }
  }
}
