Neighbourly Plans II


Submit solution

Points: 1
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Neighbourly Plans II

After graduating from RSP, Tom and Patrick can't wait to move to Sydney! Since they are such good friends, they want to live as close to each other as possible. But, they're not that good friends, so they don't want to be in the same location.

Instead, they want to live as close as possible to each other (Euclidean distance), without being in the same location.

Recently, Tom and Patrick looked at several properties. They have a list of everywhere they would each be willing to live at, including their longitude and latitude.

Which two locations are optimal for Tom and Patrick to live as close as possible, and who will live where?

Input

The first line of each test case consists of an integer n (1 \leq n \leq 10^5), the number of properties Tom is willing to live at.

The next n lines of each case are in the form x \; y (1 \leq x, y \leq 10^6), representing the position of a place Tom is willing to live at.

The next line of each case consists of an integer m (1 \leq m \leq 10^5), the number of properties Patrick is willing to live at.

The next m lines of each case are in the form x \; y (1 \leq x, y \leq 10^6), representing the position of a place Patrick is willing to live at.

Output

Output the longitude and latitude Tom should live at on one line, followed by the longitude and latitude Patrick should live at on the next line - so that Tom and Patrick live as close as possible to each other.

Note: In the case of a tie, use the earliest place in Tom's list. If it's still a tie, use the earliest place in Patrick's list.

Note: There is guaranteed to be a solution!

Example

Input
2
25 25
13 16
2
25 25
14 16
Output
13 16
14 16

The closest pair of locations Tom and Patrick they will be happy to live at are 1 unit apart.

_Note: Remember, they don't want to live in the exact same location!_

Input
3
1 1
2 2
3 3
3
3 1
2 2
1 3
Output
1 1
2 2

Comments

There are no comments at the moment.