You are given $$$n$$$ $$$d$$$-dimensional hyperrectangles with sides parallel to the axes numbered from $$$1$$$ to $$$n$$$. Each of these hyperrectangles is defined by the region of all points with real coordinates $$$(x_1,x_2,\dots,x_d)$$$ such that $$$l_i \leq x_i \leq r_i$$$ (for $$$1 \leq i \leq d$$$). For each hyperrectangle, $$$2 \cdot d$$$ integers $$$l_1, r_1, l_2, r_2, \dots, l_d, r_d$$$ are given.
You can do the following operation on the hyperrectangles:
Answer $$$q$$$ queries. In each query, you are given two integers $$$L$$$ and $$$R$$$. You have to find the minimum number of operations so the intersection of the hyperrectangles numbered from $$$L$$$ to $$$R$$$ is non-empty. In other words, there must exist a point that is contained inside all such hyperrectangles. A point in the boundary of the hyperrectangle is said to be inside the hyperrectangle.
The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \leq n \leq 10^4$$$ and $$$1 \leq d \leq 50$$$) $$$-$$$ the number of hyperrectangles and the number of dimensions.
The following $$$n$$$ lines contain the description of the hyperrectangles. Each line contains $$$2 \cdot d$$$ integers $$$l_1, r_1, l_2, r_2, \dots, l_d, r_d$$$ ($$$-10^9 \leq l_i \lt r_i \leq 10^9$$$ for $$$1 \leq i \leq d$$$) $$$-$$$ the description of the hyperrectangles.
The following line contains an integer $$$q$$$ ($$$1 \leq q \leq 10^4$$$) $$$-$$$ the number of queries.
The following $$$q$$$ lines contain the description of the queries. Each line contains $$$2$$$ integers $$$L$$$ and $$$R$$$ ($$$1 \leq L \leq R \leq n$$$) $$$-$$$ the range of each query.
Print $$$q$$$ lines with the answers to the queries.
3 22 4 2 40 2 0 2-2 0 -2 031 22 31 3
0 0 4
2 31 2 1 2 1 20 3 0 3 0 311 2
0
4 20 4 2 55 6 1 42 3 3 41 2 0 131 33 41 4
2 2 5
The diagram below shows the minimum number of operations needed in the third query of the first sample:
The operations are as follows:
After these $$$4$$$ operations, all the hyperrectangles intersect at point $$$(1,1)$$$.
Note that the first axis is the $$$x$$$-axis and the second axis is the $$$y$$$-axis in the diagram above.
| Name |
|---|


