Guaba and Computational Geometry
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

There are n rectangles on a two-dimensional plane. The i-th rectangle has a weight w_i. You should find 2 non-overlapping rectangles i and j, and make as large as possible.
2 rectangles are non-overlapping if and only if no points are inside both rectangles at the same time. For example, rectangles 1 and 3 are overlapping, as are rectangles 1 and 2, but rectangles 2 and 3 are not overlapping.

输入描述:

The first line contains an integer  --- the number of test cases.
For each test case, the first line contains an integer --- the number of rectangles.
Then n lines follow, each line contains 4 integers --- the lower left corner (a_i,b_i) and upper right corner (c_i,d_i).
The next line contains n integers --- the weight of the i-th rectangle.
It is guaranteed that over all test cases.

输出描述:

For each test case, output an integer in one line --- the maximum value of . If all rectangles overlap each other, output -1.
示例1

输入

复制
2
3
1 1 6 5
3 2 5 3
6 5 8 7
10 1 2
2
1 1 6 5
6 5 8 7
1 2

输出

复制
3
-1