#include <bits/stdc++.h>
int sum0, sum1;
int n, m;
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    sum0 = sum1 = 0;
    for (int i = 0; i < n; ++i) {
      int a;
      scanf("%d", &a);
      if (a < 0)
        ++sum0;
      else
        ++sum1;
    }
    for (int i = 0; i < m; ++i) {
      int a, b, c;
      scanf("%d%d", &a, &b);
      c = b - a + 1;
      if (c & 1)
        puts("0");
      else {
        c >>= 1;
        if (c <= (sum0 < sum1 ? sum0 : sum1))
          puts("1");
        else
          puts("0");
      }
    }
  }
  return 0;
}
