#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N, Q;
  while (cin >> N >> Q) {
    vector<int> rx(N), ry(N);
    for (int i = 0; i < N; i++) cin >> rx[i] >> ry[i];
    rx.push_back(-1.01e9); rx.push_back(1.01e9);
    ry.push_back(-1.01e9); ry.push_back(1.01e9);
    sort(rx.begin(), rx.end());
    sort(ry.begin(), ry.end());
    rx.erase(unique(rx.begin(), rx.end()), rx.end());
    ry.erase(unique(ry.begin(), ry.end()), ry.end());

    auto par = [&](int sx, int sy, int x, int y) {
      if (sx < 0 || sx+1 >= rx.size() || sy < 0 || sy+1 >= ry.size()) return -1;
      if (x <= rx[sx] || x >= rx[sx+1] || y <= ry[sy] || y >= ry[sy+1]) return -1;
      if (rx[sx+1]-rx[sx]-1 == 1 && ry[sy+1]-ry[sy]-1 == 1) return -1;
      if (rx[sx+1]-rx[sx]-1 == 1 && rx[sx]-rx[sx-1]-1 == 0 && rx[sx+2]-rx[sx+1]-1 == 0) return -1;
      if (ry[sy+1]-ry[sy]-1 == 1 && ry[sy]-ry[sy-1]-1 == 0 && ry[sy+2]-ry[sy+1]-1 == 0) return -1;
      if (rx[sx+1]-rx[sx]-1 == 3 && ry[sy+1]-ry[sy]-1 == 3 && x-rx[sx] == 2 && y-ry[sy] == 2) return -1;
      if (rx[sx+1]-rx[sx]-1 >= 3 && ry[sy+1]-ry[sy]-1 >= 3) return 0;
      return (((x-rx[sx]-1)&1) ^ (((y-ry[sy]-1)/2)&1)) +
             (((y-ry[sy]-1)&1) ^ (((x-rx[sx]-1)/2)&1)) * 2;
    };

    vector<vector<vector<int>>> comp(ry.size()-1, vector<vector<int>>(rx.size()-1, {-1,-1,-1,-1}));
    for (int i = 0; i < Q; i++) {
      int x1, y1, x2, y2;
      cin >> x1 >> y1 >> x2 >> y2;
      int sx1 = lower_bound(rx.begin(), rx.end(), x1) - rx.begin() - 1;
      int sy1 = lower_bound(ry.begin(), ry.end(), y1) - ry.begin() - 1;
      int sx2 = lower_bound(rx.begin(), rx.end(), x2) - rx.begin() - 1;
      int sy2 = lower_bound(ry.begin(), ry.end(), y2) - ry.begin() - 1;
      int p1 = par(sx1, sy1, x1, y1);
      int p2 = par(sx2, sy2, x2, y2);
      if (p1 == -1 || p2 == -1) { cout << 0 << endl; continue; }

      vector<tuple<int,int,int,int>> q{{sx1, sy1, x1, y1}};
      for (int qi = 0; qi < q.size(); qi++) {
        auto [sx, sy, x, y] = q[qi];
        int p = par(sx, sy, x, y);
        if (p == -1 || comp[sy][sx][p] != -1) continue;
        comp[sy][sx][p] = i;
        for (int d = 1; d <= 4; d++) for (int e = d-1; e <= d+1; e += 2) {
          if (p == par(sx, sy, rx[sx  ]+1, ry[sy  ]+d)) q.push_back({sx-1, sy  , rx[sx  ]-1, ry[sy  ]+e});
          if (p == par(sx, sy, rx[sx  ]+d, ry[sy  ]+1)) q.push_back({sx  , sy-1, rx[sx  ]+e, ry[sy  ]-1});
          if (p == par(sx, sy, rx[sx+1]-1, ry[sy+1]-d)) q.push_back({sx+1, sy  , rx[sx+1]+1, ry[sy+1]-e});
          if (p == par(sx, sy, rx[sx+1]-d, ry[sy+1]-1)) q.push_back({sx  , sy+1, rx[sx+1]-e, ry[sy+1]+1});
        }
      }

      cout << (comp[sy1][sx1][p1] == comp[sy2][sx2][p2]) << endl;
    }
  }
}
