#include <bits/stdc++.h>
using namespace std;
const int maxx = 2e5 + 19;
const int mod = 1000000007LL;
const long long inf = 1e9 + 7;
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  int a[maxx] = {};
  int myek = 0, yek = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == -1)
      myek++;
    else if (a[i] == 1)
      yek++;
  }
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    if ((r - l + 1) % 2)
      cout << 0;
    else {
      if (myek >= ((r - l + 1) / 2) && yek >= ((r - l + 1) / 2))
        cout << 1;
      else
        cout << 0;
    }
    cout << endl;
  }
  return 0;
}
