#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, m, i, j, one = 0;
  cin >> n >> m;
  long long int A[n];
  for (i = 0; i <= n - 1; i++) {
    cin >> A[i];
    if (A[i] == 1) one++;
  }
  for (i = 0; i <= m - 1; i++) {
    long long int x, y;
    cin >> x >> y;
    if ((y - x) % 2 == 0)
      cout << "0" << endl;
    else {
      long long int len = y - x + 1;
      if (one >= len / 2 && (n - one) >= len / 2)
        cout << "1" << endl;
      else
        cout << "0" << endl;
    }
  }
}
