You are given a strange scale (see the figure below), and you are wondering how to balance this scale. After several attempts, you have discovered the way to balance it — you need to put different numbers on different squares while satisfying the following two equations:

x_{1} * 4 | + | x_{2} * 3 | + | x_{3} * 2 | + | x_{4} | = | x_{5} | + | x_{6} * 2 | + | x_{7} * 3 | + | x_{8} * 4 |

y_{1} * 4 | + | y_{2} * 3 | + | y_{3} * 2 | + | y_{4} | = | y_{5} | + | y_{6} * 2 | + | y_{7} * 3 | + | y_{8} * 4 |

There are multiple test cases in the input file. Each test case consists of 16 distinct numbers in the range [1, 1024] on one separate line. You are allowed to use each number only once.A line with one single integer 0 indicates the end of input and should not be processed by your program.

提交代码