#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  int a;
  int x = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a == 1) {
      x++;
    }
  }
  int q, w;
  int t = min(x, n - x);
  while (m--) {
    cin >> q >> w;
    if (t >= (w + 1 - q) / 2 && (w - q) % 2 != 0) {
      cout << 1 << "\n";
    } else {
      cout << "0"
           << "\n";
    }
  }
}
