AT_arc201_a [ARC201A] CatCoder Double Contest

Description

> 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.

Input Format

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 Format

Output $ T $ lines. The $ i $ -th line should contain the maximum number of times C2C can be held for the $ i $ -th test case.

Explanation/Hint

### Sample Explanation 1 For the first test case, C2C can be held $ 2 $ times by using problem proposals as follows: Div.1Div.2 $ 1 $ st timeHard, Medium from the $ 1 $ st writerMedium, Easy from the $ 2 $ nd writer $ 2 $ nd timeHard, Medium from the $ 2 $ nd writerMedium, Easy from the $ 2 $ nd writer ### 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.