#C4076. Chess Board Pattern Generator

    ID: 47574 Type: Default 1000ms 256MiB

Chess Board Pattern Generator

Chess Board Pattern Generator

You are given two positive integers \( n \) and \( m \), representing the number of rows and columns respectively, and two characters char1 and char2. Your task is to generate a chess board pattern of dimensions \( n \times m \) using these two characters.

The pattern is constructed such that the top-left cell (i.e., cell at row 0, column 0) always contains char1. Then, the characters alternate in a chess board like manner. Specifically, for any cell at position \( (i,j) \), if \( (i+j) \) is even the cell will contain char1 and if odd it will contain char2. However, if char1 and char2 are identical, then every cell simply uses that character.

If either \( n \) or \( m \) is less than 1, output an empty result.

Note: The output must match the pattern exactly, with each row printed on a new line. All formulas are expressed in \( \LaTeX \) format.

inputFormat

The input is read from stdin and consists of two lines:

  • The first line contains two space-separated integers \( n \) and \( m \).
  • The second line contains two space-separated characters: char1 and char2.

outputFormat

The output should be printed to stdout. It is the chess board pattern as described, composed of \( n \) lines with each line containing exactly \( m \) characters. If the dimensions are invalid (i.e. \( n < 1 \) or \( m < 1 \)), output nothing.

## sample
4 4
X O
XOXO

OXOX XOXO OXOX

</p>