#include <bits/stdc++.h>
using namespace std;
inline void tc() {}
int main() {
  tc;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, a = 0, b = 0;
  cin >> n >> m;
  int ar[n];
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    if (ar[i] == 1)
      a++;
    else if (ar[i] == -1)
      b++;
  }
  int x, y, diff = 0;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    diff = abs(x - y);
    if (diff % 2 != 0 && a >= (diff + 1) / 2 && b >= (diff + 1) / 2)
      cout << 1 << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}
