#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, s = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int k;
    cin >> k;
    if (k > 0) s++;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    if ((v - u + 1) / 2 <= min(s, n - s) && (v - u + 1) % 2 == 0)
      cout << 1 << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}
