Soju

No attempts yetTime limit3sMemory limit128 MB

Problem

Two rival companies, IC and PC, share the soju market in Korea. Soju is a well-known Korean distilled liquor that goes well with Korean cuisine. The two companies have an agreement about where their branches may sit: every IC branch must lie to the west of every PC branch. In other words, all IC branches have a smaller xx-coordinate than any PC branch.

At the beginning of each month the companies check whether the agreement still holds. To do so they want the distance of the closest pair of branches, one from each company. The distance between two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is defined as x1x2+y1y2|x_1 - x_2| + |y_1 - y_2|.

Example layout of IC and PC branches

Figure 1. Blue disks are IC branches and red squares are PC branches. The distance of a closest pair between them is 5.

You are given two sets of points, II and PP, representing the branches of IC and PC respectively. Every point in II has a smaller xx-coordinate than any point in PP. Write a program that computes the minimum distance over all pairs (i,p)(i, p) with iIi \in I and pPp \in P.

Input

Your program reads from standard input. The first line contains the number of test cases TT. The first line of each test case contains an integer nn, the number of points in II (1n1000001 \le n \le 100000). Each of the following nn lines contains the xx-coordinate and yy-coordinate of one point of II. The next line contains an integer mm, the number of points in PP (1m1000001 \le m \le 100000). Each of the following mm lines contains the xx-coordinate and yy-coordinate of one point of PP. All coordinates are integers between 106-10^6 and 10610^6 inclusive. Note that every point of II has a smaller xx-coordinate than any point of PP.

Output

Your program writes to standard output. Print exactly one line for each test case. Each line contains a single integer, the distance of a closest pair of points, one from II and one from PP.