시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB0000.000%

문제

Given a decimal integer $s$, you need to permute the digits of $s$ to obtain a number divisible by $7$, or determine that it is impossible.

Leading zeroes in decimal integers are allowed in this problem.

입력

The first line contains an integer $T$, the number of test cases ($1 \le T \le 10^5$). The descriptions of test cases follow.

A test case contains exactly one line with ten integers $c_0, c_1 \dots c_9$, where $c_i$ is the number of digits $i$ in $s$ ($0 \le c_i \le 10^9$, $\sum c_i > 0$).

출력

For each test case, if it is possible, print the permuted number formatted according to the rules below. Otherwise, print $-1$.

Because the number $s$ can be very large, you have to print the permuted number in segments, from left to right. First, print a line containing an integer $k$, the number of segments ($1 \le k \le 100$). Then print $k$ more lines, the $i$-th of which will contain two integers $r_i$ and $x_i$, indicating that the $i$-th segment of digits in the permuted number consists of $r_i$ repetitions of the digit $x_i$ ($r_i \ge 0$, $0 \le x_i \le 9$).

It can be shown that, if an answer exists, then there also exists an answer which can be represented under the above constraints. If there are several possible solutions, print any one of them.

예제 입력 1

3
0 1 0 0 1 0 0 0 0 0
0 2 0 0 0 0 1 0 0 1
0 1000000000 0 0 0 0 0 0 0 0

예제 출력 1

2
1 1
1 4
3
2 1
1 6
1 9
-1