#include <bits/stdc++.h>
using namespace std;
int n, m, zero, one;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a > 0)
      one++;
    else
      zero++;
  }
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    cout << (r - l & 1 && r - l < 2 * min(one, zero)) << endl;
  }
}
