#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  unsigned long int n, m;
  int a, count1 = 0, count0 = 0, b;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a == 1)
      count1++;
    else
      count0++;
  }
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    if ((b - a) % 2 == 0) {
      cout << 0 << "\n";
      continue;
    } else {
      if ((2 * count1 - 1) >= b - a) {
        if ((2 * count0 - 1) >= b - a)
          cout << 1 << "\n";
        else
          cout << 0 << "\n";
      } else
        cout << 0 << "\n";
    }
  }
  return 0;
}
