For a cell at coordinates (x, y) in a table of size M × N, output the coordinates of its neighbours. Neighbours share a side with the given cell.
Natural numbers M, N, x, and y are given (1 ≤ x ≤ M ≤ 10⁹, 1 ≤ y ≤ N ≤ 10⁹).
Output the coordinate pairs of the neighbouring cells in any order.
Input #1
3 3 2 2
Output #1
2 1 1 2 2 3 3 2
Sign in to submit your solution and save your progress.