#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2 * 1e5 + 256;
int n, a[2 * MAXN], m, nul, one;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    if (a[i] == 1)
      one++;
    else
      nul++;
  }
  while (m--) {
    int l, r;
    scanf("%d%d", &l, &r);
    if ((r - l + 1) % 2 == 0 && one >= (r - l + 1) / 2 &&
        nul >= (r - l + 1) / 2)
      puts("1");
    else
      puts("0");
  }
  return 0;
}
