A. Hasan the lazy judge
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Since Hasan was too lazy to write a story for this problem, so we'll say it clear:

Given $$$N$$$ Horizontal lines and $$$M$$$ Vertical lines, you need to find the Longest plus sign formed by the intersection of exactly one vertical line with one horizontal line.

The length of the plus sign is defined by the length of its shortest side (the minimum length of the segments $$$[C,L1]$$$, $$$[C,L2]$$$, $$$[C,L3]$$$, $$$[C,L4]$$$.

Input

First line of input will be $$$T$$$ number of test cases.

Each test case will start with two numbers, $$$N$$$ and $$$M$$$ the number of Horizontal lines and the number of vertical lines.

Next $$$N$$$ lines contain three space separated numbers, $$$X_1$$$, $$$X_2$$$ and $$$Y$$$, the starting and ending $$$X$$$ coordinates of the horizontal line, and It's $$$Y$$$ coordinate.

Next $$$M$$$ lines contain three space separated numbers, $$$Y_1$$$, $$$Y_2$$$ and $$$X$$$, the starting and ending $$$Y$$$ coordinates of the horizontal line, and It's $$$X$$$ coordinate.

$$$ 1 \le N, M \le 10^5$$$

$$$ 1 \le coordinates \le 10^5 $$$ and all the coordinates are integers.

Output

For each test case print one line, containing the length of the longest plus sign.

Example
Input
1
3 2
1 5 3
2 4 2
6 12 6
1 5 3
6 9 2
Output
2