409353: GYM103488 G Generate 7 Colors
Description
Albedo needs some pieces of $$$7$$$ colors to paint PaiMonaLisa! Colors are numbered from $$$0$$$ to $$$6$$$. For color $$$i$$$, he needs exact $$$a_i$$$ pieces.
Albedo is a master alchemist. In one operation, he can generate a sequence $$$s$$$ of any length $$$k$$$. For the sequence $$$s_0,s_1,\dots,s_{k-1}$$$, $$$s_i=i\%7$$$ hold for $$$i\in [0,k-1]$$$. The $$$i$$$-th element indicates a piece of color $$$s_i$$$.
Please help Albedo find the minimum number of operations to generate exact $$$a_i$$$ pieces for all $$$7$$$ colors.
The first line contains an integer $$$T(1\le T\le 10^5)$$$ — the number of test cases.
Each test case is described by $$$7$$$ integers $$$a_0,a_1\dots,a_6(1\le a_i\le 10^9)$$$ in one line — the pieces Albedo needs for $$$7$$$ colors respectively.
OutputFor each test, output an integer in one line — the minimum number of operations to generate exact $$$a_i$$$ pieces for all $$$7$$$ colors. If it's impossible to do it, output -1.
ExampleInput3 2 2 2 2 1 1 1 3 3 3 3 1 1 1 1 1 1 1 1 1 1000000000Output
1 2 -1Note
For test case $$$1$$$, Albedo can use $$$1$$$ operation and generate the sequence $$$[0,1,2,3,4,5,6,0,1,2,3]$$$.
For test case $$$2$$$, Albedo can use $$$2$$$ operations and generate $$$[0,1,2,3,4,5,6,0,1,2,3]$$$ and $$$[0,1,2,3]$$$ respectively.