You are playing a simple tower defense game.
The game is played on an infinite square grid. At the beginning of the game the entire grid is empty, except for two cells. The cell contains the entrance through which enemy units will be entering the grid. The cell contains your home: a building you are trying to protect from the invaders.
Before the invaders arrive you may build up to turrets. Each turret will occupy one empty cell of the grid.
The invaders can move in four cardinal directions and always follow the shortest path from the entrance to your home. For your master plan, you require that distance to be exactly .
Input
The first line of input contains two integers: the coordinates and .
The second line of input contains two integers: the coordinates and .
The third line of input contains one integer: the desired distance .
The cells and are distinct and their distance on the empty grid is at most .
Output
If there is no solution, output a single line with the text impossible
.
If there are multiple solutions, you may output any one of them. The first line of output should contain the number of turrets you want to place . Each of the following lines should contain the coordinates of one turret.
All coordinates of all turrets must be between and , inclusive.
The checker for this task will also accept solutions that output additional and/or different whitespace between the numbers in the output.
Scoring
Subtask ( points): and .
Subtask ( points): .
Subtask ( points): no additional constraints.
Sample Input 1
10 10
20 20
14
Sample Output 1
impossible
Explanation Of Sample 1
In the first example the current distance from the entrance to your home is already . You cannot decrease it to by placing turrets.
Sample Input 2
10 20
10 50
32
Sample Output 2
2
10 47
-1000000003 -5
Explanation Of Sample 2
In the second example the invaders have to go around the turret at which increases the distance between the entrance and your home from to . The second turret in this example output is useless and illustrates that you do not have to minimize the number of turrets, and that the turrets can be placed outside the part of the grid that contains the entrance and the exit.
Sample Input 3
0 0
4 0
8
Sample Output 3
6
1 0
1 1
1 2
3 0
3 -1
4 -2
Explanation Of Sample 3
The third example output is shown below, using E
for the entrance, H
for the home and asterisks for turrets.
.......
..*....
..*....
.E*.*H.
....*..
.....*.
.......
Comments