Given axis-aligned rectangles and colored points, count the distinct color labels that reach each rectangle along the vertical stacking order.
Hard8SortingSegment treeSimulationDFSNo attempts yetTime limit2sMemory limit512 MBOne day little Donald washed all N of his white sheets. After washing them he spread them out on the ground in his backyard to dry. No two sheets touch at a corner or along an edge, and no two edges cross, but a smaller sheet may lie entirely on top of a bigger one, and one sheet may cover another one completely. Once the sheets were laid out, Donald went to bed.
Donald's friend Kim heard that the sheets were drying outside and decided to play a trick. In the attic Kim found his father's paintball gun and M paintballs. The balls come in several colours, and several balls may share the same colour. As soon as Donald fell asleep, Kim walked into the backyard and started shooting at the sheets. Sheets soak up paint, so when the topmost sheet is hit, its colour bleeds down to every sheet lying beneath it. Kim used up all the balls and left in a good mood.
In the morning Donald came out to collect the sheets and found a pile of colours he had never seen. Donald likes exact data and is too shocked to think, so he asks you to count how many new colours ended up on each sheet.
Model the backyard as an infinite coordinate plane, each sheet as a rectangle with sides parallel to the axes, and each shot as a point on that plane. A shot that lands on the boundary of a sheet counts as a hit on that sheet.
A shot may miss every sheet. The coordinates of the shots are pairwise different.
The first line contains the number of sheets N and the number of paintballs M. (1≤N≤80000, 1≤M≤80000)
The i-th of the next N lines contains the lower left corner Ai, Bi and the upper right corner Ci, Di of the i-th sheet. (1≤Ai<Ci≤109, 1≤Bi<Di≤109)
The j-th of the following M lines contains the coordinates Xj, Yj where Kim's j-th shot landed and the colour label Kj of that ball. (1≤Xj≤109, 1≤Yj≤109, 1≤Kj≤109)
Print N lines. The i-th line contains the number of new colours on the i-th sheet.
In the pictures the number next to a point is the colour label of that shot.

The picture for the first example.

The picture for the second example.