Storage box

0.55 Professor Oak has a storage box of size h×w×h \times w \times \ell (hight, width and length) in his garden. Although he is currently storing some soil and fertilizer in it, he secretly plans to use it to hide the ashes of the corpses of the students that he will catch cheating in the future. He already has a large number of small boxes for the ashes, all of size 3×2×13 \times 2 \times 1. Note that each small box can be considered as the union of six 1×1×11 \times 1 \times 1 cubes.

Given hh, ww and \ell, can you tell if it is possible to completely fill the storage box with small boxes? We can arrange each small box inside the storage box in any direction parallel to the three dimensional axes.

Moreover, if it is possible to fill the storage box, can you provide a way?

0.40

image

Input

Input consists of several cases, each with hh, ww and \ell, all natural numbers. You can assume 1h×w×1051 \le h \times w \times \ell \le 10^5.

Output

For each case, if it is impossible to fill the storage box, just print “NO”. Otherwise, print “YES” and h(w+1)h \cdot (w + 1) lines as follows: Assign a different number between 1 and 10510^5 to each small box, and print it exactly six times to describe the positions of the six 1×1×11 \times 1 \times 1 cubes of the box. Each of the hh levels of the storage box must be described with ww lines, each with \ell numbers. An additional line with 10 dashes ends each level. If there is more than one solution, you can print any one. Follow strictly the format of the sample output.

For instance, to the left of the fifth sample output for a box with heigth 3, width 2 and length 4 you can see a picture of the given solution.

image

Problem information

Author: Salvador Roura
Event: Vint-i-quatrè Concurs de Programació de la UPC - Semifinal
Date: 2026-06-18

Generation: 2026-06-10T18:39:54.658Z

© Jutge.org, 2006–2026.
https://jutge.org