#1481. 水壶问题

水壶问题

题目描述

小青遇到了这样一个问题:In the movie Die Hard 3, Bruce Willis and Samuel L. Jackson were confronted with the following puzzle. They were given a 3-gallon jug and a 5-gallon jug and were asked to fill the 5-gallon jug with exactly 4 gallons. This problem generalizes that puzzle.

输入格式

The input will consist of multiple test cases. Each test case contains six integers: Ca, Cb, N, Ca_init, Cb_init, N_goal.

输出格式

For each test case, output a sequence of actions that will leave exactly N gallons in jug B.

样例

样例 1

输入 # 1

3 5 4 0 0 4

输出 # 1

fill B
pour B A
empty A
pour B A
fill B
pour B A