#include <bits/stdc++.h>
using namespace std;
int cnt[4];
int main() {
  int n, m, x, y;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &x), cnt[x + 1]++;
  while (m--) {
    scanf("%d%d", &x, &y);
    x = y - x + 1;
    if (((x & 1) && cnt[1] || (x & 1) == 0) && cnt[0] >= (x - cnt[1] + 1) / 2 &&
        cnt[2] >= (x - cnt[1] + 1) / 2)
      puts("1");
    else
      puts("0");
  }
}
