#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
  int n, m, li, ri, i;
  cin >> n >> m;
  int sum1 = 0, sum2 = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 1)
      sum1++;
    else
      sum2++;
  }
  while (m--) {
    cin >> li >> ri;
    int res = ri - li + 1;
    if (res == 1)
      cout << "0" << endl;
    else {
      if (res % 2)
        cout << "0" << endl;
      else {
        if (res / 2 <= min(sum1, sum2))
          cout << "1" << endl;
        else
          cout << "0" << endl;
      }
    }
  }
  return 0;
}
