#K12031. Chessboard Grid Painting

    ID: 23600 Type: Default 1000ms 256MiB

Chessboard Grid Painting

Chessboard Grid Painting

You are given two positive integers (N) and (M) representing the number of rows and columns of a grid. Your task is to paint this grid in a chessboard pattern according to the following rules:

  1. The Manhattan distance between two cells ((i_1, j_1)) and ((i_2, j_2)) is defined as (|i_1-i_2| + |j_1-j_2|).
  2. A cell located at position ((i, j)) should be painted white ('W') if its Manhattan distance from the top-left cell ((1, 1)) is even; otherwise, it should be painted black ('B').

The output should be an (N \times M) grid where each row is printed on a new line and cells in a row are separated by a single space.

For example, for (N=3) and (M=3), the output should be:

W B W
B W B
W B W

inputFormat

The input consists of a single line containing two space-separated integers (N) and (M) ((1 \leq N, M \leq 1000)), where (N) is the number of rows and (M) is the number of columns.

outputFormat

The output should consist of (N) lines. Each line should contain (M) characters ('W' or 'B') separated by a single space. The pattern must follow the rules described in the problem statement.## sample

3 3
W B W

B W B W B W

</p>