Under construction

Still being built. Things may change

Quadruples of Points

Time limit5sMemory limit1024 MB

Summary
Given n sets of four points and m axis-parallel rectangles, decide for each rectangle whether it contains exactly half of the points in every set.
Level

Hard8 of 10

Topics
Geometry, Hash map, Sorting
Solved
No attempts yet

문제

"I have a rule," said the manager. "Always do only half of the work."

"Why do you have such a rule?" asked Cheburashka. It is simple, said Ivan Ivanovich. If I do all the work and agree with everything, everybody will say I am too kind and that you can do anything under my command. Otherwise, if I do no work at all and decline everything, I will be considered lazy and basically worthless. So doing only half of the work is ideal, because nobody can say anything bad about me. Do you understand now?


E. Uspenskiy, "Gena the Crocodile and his Friends"

Geologists of Flatland are planning an important research. For this purpose, they prepared nn sets of points, and are going to make measurements at these points. Each set consists of four distinct points, defined by their two-dimensional coordinates.

The prepared sets must be approved by mm managers. Each manager chooses a rectangle with sides parallel to the coordinate axes and approves measurements at all points inside the rectangle or on its border.

A manager is called fantastic if, for each given set of points, he approves exactly half of the points. Determine for each manager whether he is fantastic or not.

입력

The first line contains two integers nn and mm, the number of point sets and the number of managers (1≤n≤200 0001 \le n \le 200\,000, 1≤m≤200 0001 \le m \le 200\,000). Then follow nn groups of lines, four lines in each group. Each line contains two integers: the coordinates of the next point. In each set, all points are pairwise distinct. The next mm lines describe rectangles: four integers x1x_1, y1y_1, x2x_2, y2y_2 per line (x1≤x2x_1 \le x_2, y1≤y2y_1 \le y_2).

All coordinates do not exceed 10910^9 by absolute value.

출력

For each manager, print "YES" if, for each given set of points, he approves exactly half of the points, and "NO" otherwise.

Examples1

  1. Example 1

    Input
    2 3
    0 0
    0 1
    1 0
    1 2
    2 0
    2 -1
    2 -2
    2 -3
    0 -1 2 0
    0 -1 2 1
    0 0 0 1
    
    Expected output
    YES
    NO
    NO