#K95442. Fence Post Placement in a Grid

    ID: 38864 Type: Default 1000ms 256MiB

Fence Post Placement in a Grid

Fence Post Placement in a Grid

You are given a garden represented as an \(n \times m\) grid. Your task is to determine the positions of four fence posts to form a rectangle inside the grid. The fence posts must be placed in cells that are not on the border (i.e., avoid the peripheral cells). If the grid dimensions are too small to place the fence posts in non-boundary cells, output "Impossible".

For example, when n = 5 and m = 4, a valid placement is (2,2), (2,3), (3,2), (3,3) because all these cells are strictly inside the border. Otherwise, if n < 3 or m < 3, the answer is "Impossible".

inputFormat

The input consists of a single line containing two integers n and m separated by spaces, where:

  • n is the number of columns (width) of the grid.
  • m is the number of rows (length) of the grid.

Note: Both n and m will be provided through standard input (stdin).

outputFormat

If the garden is large enough (i.e., both n and m are at least 3), output the fixed coordinates of the four fence posts, separated by spaces in the order: row1 col1 row2 col2 row3 col3 row4 col4. The expected coordinates are 2 2 2 3 3 2 3 3.

If it is not possible to place the fence posts (i.e., when n < 3 or m < 3), output the string "Impossible".

Output should be printed to standard output (stdout).

## sample
5 4
2 2 2 3 3 2 3 3

</p>