#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e6;
;
int n, m, a, l, r, num;
int arr[2];
int main() {
  scanf("%d%d", &n, &m);
  while (n--) {
    scanf("%d", &a);
    if (a == -1)
      ++arr[0];
    else
      ++arr[1];
  }
  while (m--) {
    scanf("%d%d", &l, &r);
    if (l == r) {
      printf("0\n");
      continue;
    }
    num = r - l + 1;
    if (num % 2 != 0)
      printf("0\n");
    else {
      if (num / 2 > arr[0] || num / 2 > arr[1])
        printf("0\n");
      else
        printf("1\n");
    }
  }
  return 0;
}
