Distance to the nearest point

Given two sets SS and QQ of points on the plane, determine, for each point in QQ, the minimum of the Manhattan distances to the points in SS.

Input

Input consists of a natural nn, the coordinates of the nn points in SS, a natural mm, and the coordinates of the mm points in QQ. Assume 1n1051 \le n \le 10^5 and 0m1050 \le m \le 10^5. The coordinates are real numbers. Points can be repeated.

Output

For every point in QQ, print the Manhattan distance to its closest point in SS.

Observation

This problem tolerates an error of 10710^{-7} for each output.

Problem information

Author: Jordi Petit

Generation: 2026-01-25T10:34:18.335Z

© Jutge.org, 2006–2026.
https://jutge.org