#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, l, r, o = 0, m = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (x == 1)
      o++;
    else
      m++;
  }
  while (k--) {
    scanf("%d%d", &l, &r);
    if ((l - r) % 2 == 0)
      cout << 0 << endl;
    else {
      if (((((abs(l - r)) + 1) / 2) <= min(o, m)))
        cout << 1 << endl;
      else
        cout << 0 << endl;
    }
  }
  return 0;
}
