#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int n, m;
  cin >> n >> m;
  int s1 = 0, sm1 = 0;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      s1++;
    } else {
      sm1++;
    }
  }
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    int len = r - l + 1;
    if (len % 2 == 1) {
      cout << 0;
    } else {
      if (s1 >= len / 2 && sm1 >= len / 2) {
        cout << 1;
      } else {
        cout << 0;
      }
    }
    cout << endl;
  }
  return 0;
}
