#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a = 0, b = 0, q;
  for (int i = 0; i < n; ++i) {
    cin >> q;
    if (q == 1)
      ++a;
    else
      ++b;
  }
  int q1, q2;
  for (int i = 0; i < m; ++i) {
    cin >> q1 >> q2;
    q2 -= q1 - 1;
    if (q2 % 2 != 0) {
      cout << 0;
      cout << endl;
      continue;
    }
    if (q2 <= min(a, b) * 2)
      cout << 1;
    else
      cout << 0;
    cout << endl;
  }
  return 0;
}
