In the event of technical difficulties with Szkopuł, please contact us via email at email@example.com.
If you are familiar with IRC chat, the support team is also reachable on PIRC network (
#szkopul channel. If you are not, just use email.
Please do not ask us things like "how to solve task XYZ?".
Please remember that the support team has to sleep sometimes or go to work in real life.
A known Polish proverb is: `The apple always falls near the apple tree'1. Your task is to check this proverb experimentally. Positions of apple trees and apples can be identified with points on a plane. The distances between points are defined by Manhattan metric:
Let us assume that every apple has fallen from the apple tree closest to it.
Write a program that:
The first line of input contains two integers and (), separated with a single space and denoting the number of apple trees and the number of apples. The second line of input contains integers from the range , separated with single spaces and denoting the pairs of coordinates of apple trees: . The third line of input contains integers from the range , separated with single spaces and denoting the pairs of coordinates of apples: . We treat both apple trees and apples as points on a plane; there can be multiple apple trees and multiple apples in one point.
The first and only line of output should contain the smallest distance between an apple and its apple tree.
For the input data:
3 4 0 2 2 0 2 2 1 1 2 1 2 3 1 4
the correct result is:
Task author: Jakub Radoszewski.