Rock is a robot travelling inside a $N \times M$ grid, where the top-left corner is $(0, 0)$ and the bottom-right corner is $(N - 1, M - 1)$. We say two squares are adjacent if they share a corner or an edge. In a step, the robot walks to any of the (up to 8) adjacent squares. The robot cannot walk out of the grid.
Currently, the robot is located at $(X, Y)$. What are the squares that the robot could reach after a step? The robot cannot stay where it currently is.
Input
The first line of input contains two integers $N$ and $M$.
The second line of input contains two integers $X$ and $Y$.
Output
Output the coordinates of each square that the robot can reach after a step. You should output the squares in ascending order of the first coordinate, then the second coordinate.
Contraints
$1 \le N, M \le 10^9$
$0 \le X \le N-1$
$0 \le Y \le M-1$
Sample Test Cases
Input | Output | |
---|---|---|
10 10 5 7 |
4 6 4 7 4 8 5 6 5 8 6 6 6 7 6 8 |
|
10 20 9 19 |
8 18 8 19 9 18 |
Scoring: Per Subtask
Authored by s16f22