QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB Total points: 100

#11043. Near 2

统计

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:

$$d((x_{1}, y_{1}), (x_{2}, y_{2})) = |x_{1} - x_{2}| + |y_{1} - y_{2}|$$

Let us assume that every apple has fallen from the apple tree closest to it.

Write a program that:

  • reads a description of positions of apple trees and apples from the standard input,
  • computes the smallest distance between an apple and its apple tree,
  • writes the result to the standard output.

^{1}An English equivalent of this proverb is: 'Like father, like son' or 'Like mother, like daughter'.

Input Format

The first line of input contains two integers $ n $ and $ m $ ($1 ≤ n, m ≤ 100\,000$), separated with a single space and denoting the number of apple trees and the number of apples. The second line of input contains $2 \cdot n$ integers from the range $[0,10^{8}]$, separated with single spaces and denoting the pairs of coordinates of apple trees: $ x_{1}$ $y_{1}$ $x_{2}$ $y_{2}$ ... $x_{n} $ $y_{n}$. The third line of input contains $2 \cdot m$ integers from the range $[0,10^{8}]$, separated with single spaces and denoting the pairs of coordinates of apples: $ x'_{1}$ $y'_{1}$ $x'_{2}$ $y'_{2}$ ... $x'_{n}$ $y'_{n} $. We treat both apple trees and apples as points on a plane; there can be multiple apple trees and multiple apples in one point.

Output Format

The first and only line of output should contain the smallest distance between an apple and its apple tree.

Example

Input

3 4
0 2 2 0 2 2
1 1 2 1 2 3 1 4

Output

1