#include <bits/stdc++.h>
using namespace std;
int n, m, one = 0, fuone = 0;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int nums;
    cin >> nums;
    if (nums == 1) {
      one++;
    } else
      fuone++;
  }
  for (int i = 1; i <= m; i++) {
    int l, r;
    cin >> l >> r;
    int len = r - l + 1;
    if (len % 2) {
      cout << 0;
    } else {
      if (one >= len / 2 && fuone >= len / 2) {
        cout << 1;
      } else
        cout << 0;
    }
    cout << endl;
  }
  return 0;
}
