#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, m, o, a[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    o += (a[i] == 1);
  }
  o = min(o, n - o);
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    int len = r - l + 1;
    if (len & 1 || len / 2 > o)
      cout << 0 << endl;
    else
      cout << 1 << endl;
  }
}
