Spirit of Cola.
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
Special Judge, 64bit IO Format: %lld

题目描述

After struggling with the bamboo skewers game in Still No Money?, OC, KP, and XW decided to settle things a different way: by drinking cola.

But unfortunately, again, the cola in this world has a spirit protecting it. The spirit has posed a challenge: they must manipulate the cola in three cups to reach a specific amount t.

The three cups have capacities c_1, c_2, and c_3 liters, respectively. Initially, the cups contain w_1, w_2, and w_3 liters of cola. They are allowed to use two types of operations sanctioned by the spirit:

  1. Choose two different cups i and j, and pour min(w_i, c_j - w_j) liters of cola from cup i to j. In other words, pour cola from cup i to j until cup j is full, or cup i has run out of cola.

  2. Choose one non-empty cup that has the minimum liters of cola and turn it into sugar-free. The spirit hates sugar-free cola and will make the cup empty instantly.

To satisfy the spirit, their goal is to find out a way to make at least one cup have exactly t liters of cola and minimize the number of operations. But take it easy; if you can prove that there is no way to achieve the goal, just tell the spirit.

输入描述:

The first line contains three integers c_1, c_2, c_3 (1 \leq c_1, c_2, c_3 \leq 300), denoting the capacities of the three cups.

The second line contains three integers w_1, w_2, w_3 (0 \leq w_1, w_2, w_3 \leq 300, w_i \leq c_i), denoting the initial amount of cola in the three cups.

The third line contains one integer t (0 \leq t \leq 300), denoting the target amount of cola they need to achieve.

输出描述:

If it is possible to achieve the goal, first output one line containing one integer n, denoting the number of operations. Then output n lines, the i-th line containing three integers, denoting the amount of cola in the three cups after the i-th operation. If there are multiple ways, output any of them.

Otherwise, output -1 instead.

示例1

输入

复制
7 5 2
5 5 0
6

输出

复制
4
3 5 2
3 5 0
1 5 2
6 0 2
示例2

输入

复制
2 2 2
2 2 0
1

输出

复制
-1
示例3

输入

复制
4 9 9
4 9 0
6

输出

复制
15
0 9 4
4 5 4
0 5 8
4 1 8
3 1 9
3 0 9
0 3 9
4 3 5
0 7 5
4 7 1
2 9 1
2 9 0
0 9 2
4 5 2
0 5 6

备注:

If it is possible to achieve the goal, first output one line containing one integer n, denoting the number of operations. Then output n lines, the i-th line containing three integers, denoting the amount of cola in the three cups after the i-th operation. If there are multiple ways, output any of them.

Otherwise, output -1 instead.