#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, num;
  cin >> n >> m;
  int num_o = 0, num_no = 0;
  for (int i = 0; i < n; i++) {
    cin >> num;
    if (num == 1)
      num_o++;
    else
      num_no++;
  }
  int l, r;
  for (int i = 0; i < m; i++) {
    cin >> l >> r;
    if ((r - l + 1) % 2) {
      cout << 0;
    } else {
      if (num_o < (r - l + 1) / 2 || num_no < (r - l + 1) / 2)
        cout << 0;
      else
        cout << 1;
    }
    cout << '\n';
  }
}
