2981.New York Hotel

Time Limit: 1s Memory Limit: 256MB

Think of New York as a rectangular grid consisting of N vertical avenues numerated from 1 to N and M horizontal streets numerated 1 to M. C friends are staying at C hotels located at some street-avenue crossings. They are going to celebrate birthday of one of them in the one of H restaurants also located at some street-avenue crossings. They also want that the maximum distance covered by one of them while traveling to the restaurant to be minimum possible. Help friends choose optimal restaurant for a celebration.

Suppose that the distance between neighboring crossings are all the same equal to one kilometer.

Input Format(From the terminal/stdin)

The first line contains two integers N , M- size of the city (1 \le N,M \le 109). In the next line there is a single integer C (1 \le C \le 105)- the number of hotels friends stayed at. Following C lines contain descriptions of hotels, each consisting of two coordinates x and y (1 \le x \le N, 1 \le y \le M). The next line contains an integer H- the number of restaurants (1 \le H \le 105). Following H lines contain descriptions of restaurants in the same format.

Several restaurants and hotels may be located near the same crossing.

Output Format(To the terminal/stdout)

In the first line output the optimal distance. In the next line output index of a restaurant that produces this optimal distance. If there are several possibilities, you are allowed to output any of them.

Sample Input

Copy
10 10
2
1 1
3 3
2
1 10
4 4
  ·  \n
 \n
 · \n
 · \n
 \n
 ·  \n
 · \n

Sample Output

Copy
6
2
 \n
 \n

Submit

请先 登录

© 2025 FAQs