Convenience Zone
InterviewTime limit2sMemory limit1024 MB
Given rooms and convenience stores on an N by M grid, find the minimum of (Manhattan distance to the nearest store) times monthly rent over all rooms.
Problem
Hyeonseong, worn out from a 4-hour round trip commute, is looking for a room to rent. He only cares about the monthly rent and the distance to the nearest convenience store.
He gives every room on the map a convenience zone score and picks the room with the lowest score. The score is calculated as follows.
Convenience zone score = (distance from the room to the nearest convenience store × monthly rent)
The map is an grid. The cell in row and column is written as . If a room is at and a convenience store is at , the distance between them is .
Hyeonseong chose the room with the lowest convenience zone score. What is that score?
Input
The first line contains and , the map size, followed by , the number of rooms, and , the number of convenience stores, separated by spaces.
From the second line, the next lines each contain three integers , , separated by spaces. This means the -th room is at and its monthly rent is .
From line , the next lines each contain two integers and separated by a space. This means the -th convenience store is at .
All rooms and convenience stores are at different positions. In other words, each position holds at most one room or one convenience store.
Output
Print the convenience zone score of the room Hyeonseong chose, on the first line.
Constraints
- There is at least one room and at least one convenience store.
Hint

In the first example, the room with rent 3 and a convenience store 2 steps away has the lowest score, 6.

In the second example, the room with rent 2 and a convenience store 2 steps away has the lowest score, 4.