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 .
The three cups have capacities ,
, and
liters, respectively. Initially, the cups contain
,
, and
liters of cola. They are allowed to use two types of operations sanctioned by the spirit:
Choose two different cups and
, and pour
liters of cola from cup
to
. In other words, pour cola from cup
to
until cup
is full, or cup
has run out of cola.
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 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
![]()
, denoting the capacities of the three cups.
The second line contains three integers
![]()
, denoting the initial amount of cola in the three cups.
The third line contains one integer
![]()
, 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
, denoting the number of operations. Then output
lines, the
-th line containing three integers, denoting the amount of cola in the three cups after the
-th operation. If there are multiple ways, output any of them.
Otherwise, output
instead.
If it is possible to achieve the goal, first output one line containing one integer
, denoting the number of operations. Then output
lines, the
-th line containing three integers, denoting the amount of cola in the three cups after the
-th operation. If there are multiple ways, output any of them.
Otherwise, output
instead.