Mirror Maze
시간 제한2초메모리 제한2048 MB
각 질의 (k, d)마다 k번째 반사가 d미터 거리에 보이도록 1 이상 10^9 이하의 정수 거리 x, y를 찾고, 불가능하면 impossible을 출력한다.
문제
George's birthday is coming up, and his friends are excitedly planning his birthday party. They have already bought his presents and are now planning out the location for the party. After some deliberation, they have decided to host George's party in a mirror maze. Each section of the mirror maze consists of two parallel walls facing each other on which mirrors are placed. This creates the effect of seeing infinite reflections of oneself if you look at one of the walls.
George's friends did some research on how to build mirror mazes, and they discovered that a section of a mirror maze is fun only if the -th reflection of the viewer appears meters away when the viewer looks at one of the mirrors. George's friends feel confident that they can now build the mirror maze, but they need help figuring out where to put the mirrors so that George will have the most fun. They are planning on building sections of the maze, and they know when George enters a section of the maze he will be looking to the left. For each section of the maze, they will build a mirror meters to the left of where George will be and meters to the right. Because of construction constraints, the distances and must be integers between and . Help George's friends figure out where to place the mirrors for each section such that the -th reflection is meters away or determine it is impossible to place the mirrors to construct a fun section.
입력
The first line of input is (), the number of sections in the maze.
Each of the next lines will consist of two numbers and (), where is the distance in meters where the -th reflection should appear.
출력
Output lines, one for each section of the maze. For each section, output two numbers, and , the left and right distances of the mirrors, or "impossible" (without quotes) if no combination of left and right distances will result in the -th reflection appearing meters away.
There may be more than pair of and that satisfy the constraints, you may print any such pair as long as . It can be shown that if it is possible to place mirrors to create a fun section then there is a pair and such that which creates a fun section.