#C6927. Optimal Game Piece Placement

    ID: 50741 Type: Default 1000ms 256MiB

Optimal Game Piece Placement

Optimal Game Piece Placement

Given a starting cell \((a, b)\) on a 20 × 20 grid and an integer \(n\) representing the number of game pieces, determine an optimal placement of the pieces. The placement strategy is defined as follows:

  • The first piece must always be placed at \((a, b)\).
  • For each increasing integer \(i \ge 1\), if additional pieces are needed, add pieces in the following order (provided the total count does not exceed \(n\)):
    • \((a+i, b)\)
    • \((a-i, b)\)
    • \((a, b+i)\)
    • \((a, b-i)\)

The output should list exactly \(n\) coordinates following the order described.

inputFormat

The input consists of a single line containing three space-separated integers: \(a\), \(b\), and \(n\), where \((a, b)\) is the starting coordinate and \(n\) is the number of game pieces to place.

outputFormat

Output \(n\) lines to standard output, each line containing two space-separated integers representing the coordinates \((i, j)\) of a game piece, in the order they were placed.

## sample
0 0 1
0 0

</p>