6968.Filling Trominos

Time Limit: 1s Memory Limit: 512MB

Your task is to fill an $n \times m$ grid using L-trominos (three squares that have an L-shape). For example, here is one way to fill a $4 \times 6$ grid:

2423-1.png

Input Format(From the terminal/stdin)

The first input line has an integer $t$ : the number of tests.

After that, there are $t$ lines that describe the tests. Each line has two integers $n$ and $m$ .

  • $1 \le t \le 100$
  • $1 \le n,m \le 100$

Output Format(To the terminal/stdout)

For each test, print YES if there is a solution, and NO otherwise.

If there is a solution, also print $n$ lines that each contain $m$ letters between A–Z. Adjacent squares must have the same letter exactly when they belong to the same tromino. You can print any valid solution.

Sample Input

Copy
2
4 6
4 7
 \n
 · \n
 · \n

Sample Output special judge

Copy
YES
AADDBB
ACCDEB
BCAEEC
BBAACC
NO
   \n
      \n
      \n
      \n
      \n
  \n
Source: CSES, Construction Problems, 2423

Submit

请先 登录

© 2025 FAQs