#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, l, r, i, hold;
  cin >> n >> m;
  int count_positive = 0, count_negative = 0;
  int *arr = new int[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] == 1)
      count_positive++;
    else
      count_negative++;
  }
  for (i = 0; i < m; i++) {
    cin >> l >> r;
    if ((r - l + 1) % 2 == 1)
      cout << "0\n";
    else {
      hold = (r - l + 1) / 2;
      if (count_positive >= hold && count_negative >= hold)
        cout << "1\n";
      else
        cout << "0\n";
    }
  }
}
