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 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 numbers of chocolates left of each type.”
For more clarification “If you distribute the chocolates among children and give numbers of each type to each child then , and . Now, you have to maximize .”
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 , denoting the number of test cases.
The first line of each test case contains three integers .
The second line of each test case also contains three integers .
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.
2 29 50 75 1 2 3 1 1 1 1 1 1