Limits
1s, 512 MB

Muntasir is a university student. His mother is struggling with 3 blocks in her heart and her condition is very serious. He lost his father long ago. For the treatment of his mother, he needs a big amount of money. That’s why he does a lot of tuitions and besides tuitions, he also teaches at a coaching center. However, Muntasir loves teaching. He always tries to encourage his students to study.

He teaches math at coaching. Sometimes he gives some interesting maths to his students. Now, we will talk about one of these maths. The math statement is like that “You have 3 types of chocolates and $a, b, c$ numbers of each type. You want to distribute the chocolates among the **maximum** number of children in such a way that after distributing each type of chocolates **equally** there will be $x, y, z$ numbers of chocolates left of each type.”

**For more clarification** “If you distribute the chocolates among $n$ children and give $p, q, r$ numbers of each type to each child then $n\times p+x=a$, $n\times q+y=b$ and $n\times r+z=c$. Now, you have to maximize $n$.”

**Note:** After distributing, each child must get at least one chocolate of each type.

As a programmer, can you find the answer to the math before Muntasir’s students?

Input starts with an integer $T (1 ≤ T ≤ 100)$, denoting the number of test cases.

The first line of each test case contains three integers $a, b, c (1 ≤ a, b, c ≤ 10^{18})$.

The second line of each test case also contains three integers $x(0 ≤ x ≤ a), y(0 ≤ y ≤ b), z(0 ≤ z ≤ c)$.

For each test case, If it's impossible to fulfill the requirements, print **"Impossible"**(without quotes). Otherwise, print one integer, the **maximum** number of children who will get chocolates.

Input | Output |
---|---|

2 29 50 75 1 2 3 1 1 1 1 1 1 | 4 Impossible |

Login to submit.

Toph uses cookies. By continuing you agree to our Cookie Policy.