#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N], n, m, ps[N], l, r, t1[N], t0[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    t1[i] = t1[i - 1] + (a[i] == 1);
    t0[i] = t0[i - 1] + (a[i] == -1);
  }
  while (m--) {
    cin >> l >> r;
    int x, y;
    x = t1[r] - t1[l - 1];
    y = t0[r] - t0[l - 1];
    if (abs(x - y) % 2 == 0) {
      if (x - y >= 0 && (x - y) / 2 <= t0[n] - y)
        cout << 1 << endl;
      else if (x - y <= 0 && abs(x - y) / 2 <= t1[n] - x)
        cout << 1 << endl;
      else
        cout << 0 << endl;
    } else
      cout << 0 << endl;
  }
  return 0;
}
