Problem P
Mirror Maze
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
Input
The first line of input is
Each of the next
Output
Output
There may be more than
Sample Explanation
-
In the first section of the maze, placing a mirror 3 meters to the left will cause the first reflection to appear 6 meters away.
-
In the second section of the maze and by placing the mirrors 1 meter left and 6 meters right, the first reflection appears 2 meters away, the second reflection appears 14 meters away, and the third reflection appears 16 meters away.
-
In the third section of the maze, no combination of integer distances will cause the second reflection to appear 5 meters away.
-
In the fourth section of the maze, the first reflection appears 4 meters away and the second reflection appears 10 meters away.
Sample Input 1 | Sample Output 1 |
---|---|
4 1 6 3 16 2 5 2 10 |
3 1 1 6 impossible 2 3 |