#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int n1 = 0;
  for (int i = 0; i < n; i++)
    if (a[i] == 1) n1++;
  int x = min(n1, n - n1);
  for (int j = 0; j < m; j++) {
    int l, r;
    cin >> l >> r;
    int w = r - l + 1;
    if (w % 2 == 0 && w <= x * 2)
      cout << 1;
    else
      cout << 0;
    cout << "\n";
  }
  return 0;
}
