433. Japhshan and Ramshut
Time limit per test: 0.75
Memory limit: 262144
Today Japhshan and Ramshut are laying the pavement in front of Mrs. Kotchak's house. Pavement has the form of a rectangle of size M
. Our workers have an infinite number of bricks of sizes 1 x L1
, 1 x L2
,..., 1 x LK
at their disposal (the bricks were laying around unused at the nearby construction site). Your task is to find a way to compose a pavement out of these bricks (without holes and overlaps) or to determine that it is impossible.
The first line of input contains three integer numbers N
, 2 ≤ M
≤ 20, 1 ≤ K
≤ 5). Second line contains K
numbers — lengths of bricks. All brick lengths are positive and do not exceed 1000.
If it is possible to compose the pavement, output "YES
" (without quotes) on the first line, then N
lines of M
lowercase Latin letters describing the composition. Two adjacent letters should be the same if they are related to the same brick, and different otherwise. If the composition is impossible, output "NO
" (without quotes). If there is more than one way to compose the pavement, output any.
5 5 2