433. Japhshan and Ramshut
Time limit per test: 0.75 second(s)
Memory limit: 262144 kilobytes
input: standard
output: standard
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 x
N. 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.
Input
The first line of input contains three integer numbers
N,
M and
K (
, 2 ≤
M +
N ≤ 20, 1 ≤
K ≤ 5). Second line contains
K numbers — lengths of bricks. All brick lengths are positive and do not exceed 1000.
Output
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.
Example(s)
sample input | sample output |
5 5 2
3 4
|
YES
aaaab
ccccb
adddb
acccc
abbbb
|