The first line of input is a number T (), which is the number of test cases.
For each test case, there will be 4 lines, representing a matrix. Each line is 4 integers separated by space, representing one row of the matrix.
The j-th integer on i-th line(
,
) denotes number of cars attempting to drive from the i-th direction to j-th direction, where the i-th direction means N, E, S, W for i=1,2,3,4 respectively. For example,
corresponds to S->E.
For each test case, output one number, which is the minumum number of seconds to resolve the traffic jam.
For example 1, there are only 3 cars running from the same direction, and they can go simultaneously.For example 2, here is what could happen during the 17 seconds.1. N->W, W->S, E->W
2. E->N, E->W, S->W, W->S
3. N->W, E->S, E->W
4. S->E, E->S, E->W
5. W->S, E->S, W->N
6. E->S, N->W, W->N
7. W->S, E->S, W->N
8. W->S, N->E, S->W
9. N->W, N->E, S->W
10. W->S, N->E, S->W
11. S->E, E->W, W->E
12. E->W, W->S, W->E
13. S->E, E->W, W->E
14. S->E, E->W, W->E
15. S->E, E->W, W->E
16. S->E, N->S, S->N
17. S->N, S->W, W->S