#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  const int maxN = 2 * 1e5;
  int answers[maxN];
  int n, m, x, neg = 0, pos = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == -1)
      neg++;
    else
      pos++;
  }
  int li, ri, range;
  for (int i = 0; i < m; i++) {
    cin >> li >> ri;
    range = ri - li + 1;
    if (range % 2 != 0)
      answers[i] = 0;
    else if (pos >= range / 2 && neg >= range / 2) {
      answers[i] = 1;
    } else {
      answers[i] = 0;
    }
  }
  for (int i = 0; i < m; i++) {
    cout << answers[i] << endl;
  }
  return 0;
}
