#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int minus = 0, plus = 0;
  signed int arr;
  cin >> n >> m;
  int i, j;
  for (i = 1; i <= n; i++) {
    cin >> arr;
    if (arr == 1)
      plus++;
    else
      minus++;
  }
  int l, r;
  for (i = 1; i <= m; i++) {
    cin >> l >> r;
    if (!((r - l + 1) % 2) && (r - l + 1) / 2 <= plus &&
        (r - l + 1) / 2 <= minus)
      cout << "1" << endl;
    else
      cout << "0" << endl;
  }
  return 0;
}
