#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, m, l, r, num, menos, mas;
  cin >> n >> m;
  menos = mas = 0;
  for (int i = 0; i < n; ++i) {
    cin >> num;
    if (num < 0)
      menos++;
    else
      mas++;
  }
  for (int i = 0; i < m; ++i) {
    cin >> l >> r;
    if ((r - l) % 2 == 0)
      cout << "0\n";
    else {
      if (menos >= (r - l + 1) / 2 && mas >= (r - l + 1) / 2)
        cout << "1\n";
      else
        cout << "0\n";
    }
  }
  return 0;
}
