1045:Water

时间限制: 2 S | 内存限制: 65536 KB
Accept: 0 | Submit: 0
[提交] [状态] [讨论版]
描述

Give three cups, size is differ, and only one of the largest glass is filled with water, the other two empty cup. Between the three cups water, and water glass without tags, can only be calculated according to water volume. Now you are asked to write a program to make the output of the initial state to goal state minimum number.

输入

The first line of an integer N (0 < N < 50) said N group of test data

The next test data have two lines in each group, the first line are three integers V1 V2 V3 (V1 > V2 > V3 V1 < 100 V3 > 0) said the three water volume.

The second line gives three integer E1, E2, E3 (volume is less than or equal to the corresponding water volume) said we need a final state

输出

Each row of the output corresponding test data with the least number of water. If can not meet the target state output -1

样例输入

2

6 3 1

4 1 1

9 3 2

7 1 1

样例输出

3

-1

HINT


来源
XUJC OJ