Another Brick in the Wall

Simulate laying bricks in pile order across h layers of width w, and report whether every layer fills exactly before the pile runs out.

Easy3SimulationImplementationArrayGreedyInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

The construction worker previously known as Lars keeps a large pile of bricks. Every brick has height 11, and the lengths differ. Lars wants to build a wall of width ww and height hh. He knows that the subset sum problem is NP-hard, so he does not try to optimize the placement. He takes the bricks in the order they sit in the pile and hopes they fit.

Lars fills the first layer from left to right. Once that layer is full he moves up to the second layer and fills it the same way, then the layer above it, and so on. He lays every brick flat and never rotates it, so a single brick never covers two layers. If the brick he picks up is longer than the space left in the current layer, he cannot place it, so he leaves the layer unfinished, gets annoyed and walks away. Bricks left over after the wall is finished do not matter.

Yesterday Lars found out only at the last layer that he could not finish the wall, got really annoyed, and tore it down. Tell him whether the pile he brought today finishes the wall.

Input

The first line contains three integers hh, ww, nn (1h1001 \le h \le 100, 1w1001 \le w \le 100, 1n100001 \le n \le 10000), the height of the wall, the width of the wall, and the number of bricks.

The second line contains nn integers xix_i (1xi101 \le x_i \le 10), the lengths of the bricks in pile order.

Output

Print YES if Lars finishes the wall, and NO otherwise.