Robbery on the Silk Road has grown, and fewer and fewer merchants travel along it. A robber posted anywhere on the route demands as much money as he can from every merchant who passes. Merchants now prefer other routes even when that makes their journey longer, so the robbers' income has fallen. Moradbeig, the chief of the robbers, has replaced the old practice with a toll system.
Under this system each robber is confined to one square area, boundary included, called his territory. Territories are not assumed to be disjoint. The toll inside any territory is exactly 1 Oshloob. The remaining rules are these.
Marco Polo, a wealthy merchant, plans to travel the Silk Road from its beginning to its end. The situation is better than it was, and he still wants to pay less toll. Write a program that computes the minimum toll Marco Polo has to pay to traverse the whole route. The Silk Road is a rectilinear path, so every segment of it is either horizontal or vertical.
The input holds several test cases. Each test case starts with a line containing two positive integers n and m (n,m≤1000), the number of territories and the number of vertices of the Silk Road. The next n lines describe the territories, one per line. Each of those lines contains non-negative integers x, y and k (x,y≤106, k≤1000), where (x,y) is the lowest and leftmost corner of the territory and k is its side length. Each of the next m lines gives the coordinates of a vertex of the Silk Road, in the order the vertices appear along the route. The route does not intersect itself. The input ends with a line containing 0 0, which is not processed.
For each test case, print one line with the minimum toll Marco Polo must pay.