#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int c0 = 0, c1 = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x == 1)
      c1 += 1;
    else
      c0 += 1;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (a == b)
      cout << 0 << endl;
    else {
      int req = b - a + 1;
      if (req % 2 != 0)
        cout << 0 << endl;
      else {
        int am = req / 2;
        if (am <= c0 && am <= c1)
          cout << 1 << endl;
        else
          cout << 0 << endl;
      }
    }
  }
  return 0;
}
