AT_arc201_f [ARC201F] CatCoder Triple Contest
Description
> The problem setting of this problem is partially shared with Problem A.
In the year $ 3333 $ , CatCoder will hold the CatCoder Triple Contest (abbreviated as C3C).
There are $ N $ writers who have problem proposals. Each writer's problem proposals are classified into $ 5 $ types by difficulty: Hell, Hard, Medium, Easy, Baby, and the $ i $ -th writer has $ A_i,B_i,C_i,D_i,E_i $ problem proposals of Hell, Hard, Medium, Easy, Baby, respectively.
Each C3C simultaneously holds $ 3 $ divisions, Div.1, Div.2, and Div.3. The problem proposals required for each division are as follows:
- Div.1: One Hell, one Hard, and one Medium problem proposal from the same writer
- Div.2: One Hard, one Medium, and one Easy problem proposal from the same writer
- Div.3: One Medium, one Easy, and one Baby problem proposal from the same writer
Note that **the writers for Div.1, Div.2, and Div.3 do not necessarily have to be the same**. Also, each problem proposal can be used in at most one division of one C3C.
For $ k=1,2,\dots,N $ , let $ X_k $ be the maximum number of times C3C can be held using only the problem proposals of the first $ k $ writers. Find $ X_1,X_2,\dots ,X_N $ .
$ 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 $ $ D_1 $ $ E_1 $ $ A_2 $ $ B_2 $ $ C_2 $ $ D_2 $ $ E_2 $ $ \vdots $ $ A_N $ $ B_N $ $ C_N $ $ D_N $ $ E_N $
Output Format
Output $ T $ lines.
The $ i $ -th line should contain $ X_1,X_2,\dots ,X_N $ separated by spaces for the $ i $ -th test case.
Explanation/Hint
### Sample Explanation 1
For the first test case, for example when $ k=2 $ , C3C can be held $ 2 $ times by using problem proposals as follows:
Div.1Div.2Div.3 $ 1 $ st timeHell, Hard, Medium from the $ 1 $ st writerHard, Medium, Easy from the $ 1 $ st writerMedium, Easy, Baby from the $ 2 $ nd writer $ 2 $ nd timeHell, Hard, Medium from the $ 2 $ nd writerHard, Medium, Easy from the $ 1 $ st writerMedium, Easy, Baby 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,D_i,E_i \le 10^9 $
- The sum of $ N $ over all test cases is at most $ 2 \times 10^5 $ .
- All input values are integers.