Imagine there are several lines in an one dimensional space. You are given the starting and ending points of all of these lines.
Given another pair of points, you have to determine the number of lines that goes through that region.
In the diagram you can see that the purple, red and orange lines are visible between the two vertical black lines (boundary). In this scenario the answer would be 3.
A line falls within the boundary of the two vertical lines even if it touches the point. For example, if the ending point of a line touches the starting boundary the line is considered to have fallen within the boundary.
The input will start with two integers () and (). is the number of lines and is the number of queries.
Next lines will follow. Each line will have a pair of 32-bit signed integers. These pair of integers represent the starting point and ending point of a line.
Next lines will follow. Each line will have a pair of 32-bit signed integers. These pair of integers represent the starting point and ending point of the boundary. You will have to determine how many lines fall within this boundary as described in the problem statement.
For each of the queries you have to print the number of lines that has fallen within the given boundary.
5 1 -3 3 -4 -2 -2 2 8 12 12 14 0 10
This sample test case has been visualized roughly in the problem statement.