Олимпиадный тренинг

Задача 37539. Endless table


Natural numbers are written in an (infinite) table, as shown.

It is required to display all its neighbors for a given number (the numbers written in the cells above, on the right, on the left and below, if any).
 

Input data: Enter one natural number not exceeding 109.
Output: The program should output all the numbers written in adjacent data cells in ascending order. Numbers must be separated by spaces.

Examples
# Input Output
1 1 3
2 7 3 6 8 13

Запрещенные операторы:for;while;until