N swimmers represented IIT Delhi in the recent Inter IIT Parivartan Meet. The i-th of the N swimmers got Gi Gold medals, Si Silver medals, and Bi Bronze medals. We define a podium finish to be a top-three finish - that means a finish that awards the swimmer a medal. There are individual events as well as relay events. Relay events are done in teams of four distinct individuals. Individual events award a single medal to each swimmer with a podium finish. Relay events award a medal each to all members of the teams with a podium finish. You are given the medal distribution of all swimmers, and you want to calculate the minimum and maximum possible number of podium finishes by the swimmers of IIT Delhi through some combination of individual and relay events. Note that a relay event awards a single podium finish to any team in the top three, not 4 podium finishes.
In each test case, the first line of the input consists of a single integer N.
N lines follow. Each of the N lines consists of three space-separated integers Gi, Si, and Bi.
Constraints
1 ≤ T ≤ 10
1 ≤ N ≤ 105
0 ≤ G, S, B ≤ 9
1
4
1 1 1
1 1 1
1 1 1
2 1 1
Sample Output
4 13
Explanation
The maximum number of podium finishes is 13 because it is possible to make all athletes participate in distinct individual events and have them win medals according to the input, that is, swimmer 1 wins 1 Gold medal, 1 Silver medal, 1 Bronze medal, and swimmer 2 wins 1 Gold medal, 1 silver medal, 1 Bronze medal and so on.
The minimum number of podium finishes is 4 because you can first form a team of swimmers (1, 2, 3, 4) and have them come 3-rd place in some relay event, 2-nd place in some relay event, and 1-st place in some relay event. Since swimmer 4 still has 1 Gold medal left, it must be possible only by participating in some individual event, giving a total of 3 + 1 = 4 total podium finishes.