시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB270786528.139%

문제

In the wonderful land of Robotopia, life is better than ever. This is thanks to all the robots, who work hard together. Different types of robots come in different forms, that is, different numbers of arms and different numbers of legs. By day, when they are working, robots are grouped so they can be assigned to different tasks. But by night, it is your job to count how many robots there are of each type within each group. Robots are naughty and energetic; they don’t like to stand still and it is difficult to count them. After many exhausting attempts, you are finally able to count how many arms and how many legs there are in total.

We know each group consists of exactly two different types of robots, with at least one of each type in each group. We also know the number of arms and legs that each type of robot has. Can you find out how many robots of each type there are within each group?

입력

The first line contains an integer n (1 ≤ n ≤ 100). The following n lines each contain one test case. Each has six integers: l1 a1 l2 a2 lt at, where l1 and a1 are the number of legs and arms (respectively) for the first type of robot, l2 and a2 are those for the second type, and lt and at are the total number of observed legs and arms. All values are in the range [1, 10 000].

출력

For each test case output two positive integers denoting the number of each of the two types of robots. Give first the count for the first type listed. If the test case has no solution or multiple solutions, output “?” (a question mark).

예제 입력 1

3
2 1 4 1 16 5
3 2 5 1 9 4
1 2 3 6 8 16

예제 출력 1

2 3
?
?

출처

ICPC > Regionals > North America > North America Qualification Contest > ACM-ICPC North America Qualifier 2016 K번

  • 문제를 만든 사람: Xiaoyuan Suo