# 2015 German Collegiate Programming Contest (GCPC)

# Carpets

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:

The entire floor is covered.

The carpets do not overlap.

The carpets are rotated arbitrarily.

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 **w** and **h** describing the size of his room (**1** ≤ **w**, **h** ≤ **100**). The second line contains an integer **c** (**1** ≤ **c** ≤ **7**), denoting the number of different carpet colours the supermarket has in stock.

Each of the following **c** lines consists of three integers `a`

, _{i}`w`

and _{i}`h`

, which means: the supermarket’s stock contains _{i}`a`

carpets of size _{i}`w`

, _{i}`h`

and color _{i}**i** (**1** ≤ `a`

≤ _{i}**7**, **1** ≤ `w`

≤ _{i}**100**, **1** ≤ `h`

≤ _{i}**100**).

The supermarket has at most **7** carpets, i.e. sum of `a`

≤ _{i}**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.

2 4 2 3 1 3 2 2 1

yes

100 100 3 4 42 42 1 100 16 1 32 42

no