#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int s1 = count(arr, arr + n, 1);
  int s2 = count(arr, arr + n, -1);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if ((b - a + 1) % 2 != 0) {
      printf("%d\n", 0);
    } else {
      int c = (b - a + 1) / 2;
      if (s1 >= c && s2 >= c) {
        printf("%d\n", 1);
      } else {
        printf("%d\n", 0);
      }
    }
  }
}
