#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  vector<int> n(a);
  int c1 = 0;
  int c2 = 0;
  for (int i = 0; i < a; ++i) {
    cin >> n[i];
    if (n[i] == 1)
      c1++;
    else
      c2++;
  }
  int l, r;
  for (int i = 0; i < b; ++i) {
    cin >> l >> r;
    int sub = r - l + 1;
    if (sub % 2 == 0) {
      if (c1 >= (sub / 2) && c2 >= (sub / 2))
        cout << "1" << endl;
      else
        cout << "0" << endl;
    } else
      cout << "0" << endl;
  }
  return 0;
}
