Carpets#7709

Carpets

2 seconds
128 megabytes
Easy

The computer science Professor Toving Liles loves the floor tiles in his office so much that he wants to protect them from damage by careless students. Therefore, he would like to buy cheap small rectangular carpets from the supermarket and cover the floor such that:

1. The entire floor is covered.

2. The carpets do not overlap.

3. Carpets can be rotated arbitrarily.

4. No carpet is cut into pieces.

But when checking the supermarket's stock he begins to wonder whether he can accomplish his plan at all. Can you help him?

Input

The first line contains two integers and describing the size of his room (1 \le w, h \le 100). The second line contains an integer (1 \le c \le 7), denoting the number of different carpet colours the supermarket has in stock.

Each of the following lines consists of three integers a_i, w_i and h_i, which means: the supermarket's stock contains a_i carpets of size w_i, h_i and color (1 \le a_i \le 7, 1 \le w_i \le 100, 1 \le h_i \le 100).

The supermarket has at most carpets, i.e. sum of a_i \le 7.

Output

For the given room dimensions and the supermarket's stock of carpets, print **"yes"** if it is possible to cover the room with carpets as specified above and **"no"** otherwise.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading