Alien Invaders

No attempts yetTime limit3sMemory limit256 MB

Problem

Aliens have invaded Earth. If you do not defend yourself, you die. Or you get assimilated. You might even get eaten. Nobody is quite sure which.

The aliens attack on a fixed schedule. There are nn aliens, and alien ii appears at time aia_i at distance did_i and attacks you at time bib_i. You therefore have to destroy alien ii at some time between aia_i and bib_i, inclusive.

Your weapon is a photon bomb whose blast power you can set to any value. If you set the power to RR and detonate the bomb, every alien that is on the field at that moment and stands at distance at most RR dies instantly, and the bomb burns RR units of fuel. You may detonate a bomb at any time and as many times as you want.

Find the smallest amount of fuel that destroys every alien without letting any of them attack you.

Input

The first line has the number of test cases TT.

Each test case starts with a line holding the number of aliens nn (1n300)(1 \le n \le 300). The next nn lines hold aia_i, bib_i, did_i (1ai<bi10000, 1di10000)(1 \le a_i < b_i \le 10000,\ 1 \le d_i \le 10000) for alien ii, separated by spaces.

Output

For each test case, print the smallest amount of fuel that destroys every alien, one answer per line. The answer is always an integer.