#K68172. Alternating Cake Grid

    ID: 32806 Type: Default 1000ms 256MiB

Alternating Cake Grid

Alternating Cake Grid

You are given two positive integers \(m\) and \(n\) representing the number of rows and columns respectively. Your task is to generate a grid of cakes that follows an alternating pattern, similar to a chessboard. Each cake is represented by either 'P' (plain) or 'I' (icing). The grid must be constructed such that for any cell located at row \(i\) and column \(j\), if \((i + j) \mod 2 = 0\) then the cake is 'P'; otherwise, it is 'I'. This pattern ensures that no two adjacent cakes (horizontally, vertically, or diagonally) are of the same type.

The resulting grid should be printed as \(m\) lines of output, each containing a continuous string of characters without spaces.

Example: For input 2 2, a valid output is:

PI
IP

inputFormat

The input is provided via standard input (stdin) and consists of a single line containing two space-separated integers \(m\) and \(n\). \(m\) denotes the number of rows and \(n\) denotes the number of columns.

Example:

3 4

outputFormat

Output the resulting cake grid via standard output (stdout). The grid should consist of \(m\) lines, each containing a string of \(n\) characters ('P' or 'I').

Example corresponding to the input above (one possible answer):

PIPI
IPIP
PIPI
## sample
2 2
PI

IP

</p>