#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 2;
const int INF = 1e9 + 7;
int main() {
  int n, m, a;
  scanf("%d %d", &n, &m);
  int pos = 0, neg = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a == 1) {
      pos++;
    } else {
      neg++;
    }
  }
  int l, r, c;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &l, &r);
    c = r - l + 1;
    if (c % 2 != 0) {
      printf("0\n");
    } else {
      if (min(pos, neg) >= (c / 2)) {
        printf("1\n");
      } else {
        printf("0\n");
      }
    }
  }
  return 0;
}
