#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, m, neg = 0, pos = 0;
  cin >> n >> m;
  long long int arr[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    if (arr[i] == -1)
      neg++;
    else
      pos++;
  }
  while (m--) {
    long long int l, r;
    cin >> l >> r;
    if ((r - l + 1) % 2 != 0 || (l == r))
      cout << "0" << endl;
    else {
      int x = r - l + 1;
      if (pos >= x / 2 && neg >= x / 2)
        cout << "1" << endl;
      else
        cout << "0" << endl;
    }
  }
  return 0;
}
