Given points and queries, both of the form , , determine the Manhattan distance of the point closest to each query.
Manhattan distance is defined as the distance between two points measured along horizontal and vertical lines only.
All points and queries will be in the first quadrant ().
Input Specifications
The first line contains the integers, and where and .
The next lines contains 2 space separated integers , representing a single point.
The next lines contains 2 space separated integers , representing a single query.
Output Specifications
For each query, output the minimum Manhattan distance to it from any point.
Sample Input 1
3 3
1 1
500 500
1000 1000
1 1
350 321
221 55
Sample Output 1
0
329
274
Comments