Problem Statement
The problem setting of this problem is partially shared with Problem F.
In the year $2222$, CatCoder will hold the CatCoder Double Contest (abbreviated as C2C).
There are $N$ writers who have problem proposals. Each writer's problem proposals are classified into $3$ types by difficulty: Hard, Medium, Easy, and the $i$-th writer has $A_i$, $B_i$, $C_i$ problem proposals of Hard, Medium, Easy, respectively.
Each C2C simultaneously holds $2$ divisions, Div.1 and Div.2. The problem proposals required for each division are as follows:
- Div.1: One Hard and one Medium problem proposal from the same writer
- Div.2: One Medium and one Easy problem proposal from the same writer
Note that the writers for Div.1 and Div.2 do not necessarily have to be the same. Also, each problem proposal can be used in at most one division of one C2C.
Find the maximum number of times C2C can be held.
$T$ test cases are given, so find the answer for each.
Constraints
$1 \le T \le 10^5$$1 \le N \le 2 \times 10^5$$1 \le A_i,B_i,C_i \le 10^9$- The sum of
$N$over all test cases is at most$2 \times 10^5$. - All input values are integers.
Input
The input is given from Standard Input in the following format:
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
Each test case is given in the following format:
N
A_1 B_1 C_1
A_2 B_2 C_2
\vdots
A_N B_N C_N
Output
Output $T$ lines.
The $i$-th line should contain the maximum number of times C2C can be held for the $i$-th test case.
样例
5
2
3 1 4
1 5 3
1
1 1 1
3
5 7 5
1 11 99
3 1 2
5
1000000000 1000000000 1000000000
1000000000 1000000000 1000000000
1000000000 1000000000 1000000000
1000000000 1000000000 1000000000
1000000000 1000000000 1000000000
6
835549144 866512240 105679868
473233032 625162103 823002638
125467290 37501686 380787083
8043910 721085797 254272563
97327826 744196952 18713225
978152989 90127986 33086297
2
0
7
2500000000
998830769
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。