#K50182. Alternating Fruit Pattern Grid

    ID: 28808 Type: Default 1000ms 256MiB

Alternating Fruit Pattern Grid

Alternating Fruit Pattern Grid

You are given two integers \(r\) and \(c\) representing the number of rows and columns respectively. Your task is to generate a grid where each cell is filled with either the letter A (representing an apple) or B (representing a banana) in an alternating pattern.

The rule to determine the character at position \((i, j)\) (0-indexed) is:

[ \text{char}_{ij} = \begin{cases} A & \text{if } (i+j) \mod 2 = 0, \ B & \text{if } (i+j) \mod 2 = 1. \end{cases} ]

Print the generated grid with each row on a new line.

inputFormat

The input is read from standard input (stdin) and consists of one line containing two integers:

  • r (1 ≤ r ≤ 1000): The number of rows.
  • c (1 ≤ c ≤ 1000): The number of columns.

The two numbers are separated by spaces.

outputFormat

Output to standard output (stdout) the generated grid consisting of r lines. Each line is a string of length c where the character is either A or B following the alternating pattern as described.

## sample
3 4
ABAB

BABA ABAB

</p>