Carpets

No attempts yetTime limit1sMemory limit256 MB

Problem

Professor Toving Liles of the computer science department likes the floor tiles in his office so much that he wants to protect them from careless students. He plans to buy cheap small rectangular carpets at the supermarket and cover the floor so that all four rules hold:

  1. The entire floor is covered.
  2. No two carpets overlap.
  3. A carpet may be turned by 90 degrees, so a w×hw \times h carpet can also be laid as an h×wh \times w carpet.
  4. No carpet is cut into pieces.

Every carpet is laid with its sides parallel to the walls, and the professor does not have to buy the whole stock. Decide whether he can carry out his plan.

Input

The first line contains two integers WW and HH, the width and the height of the room (1W,H1001 \le W, H \le 100).

The second line contains an integer cc, the number of carpet colors the supermarket has in stock (1c71 \le c \le 7).

Each of the following cc lines contains three integers aia_i, wiw_i and hih_i, meaning that the supermarket has aia_i carpets of size wi×hiw_i \times h_i in color ii (1ai71 \le a_i \le 7; 1wi1001 \le w_i \le 100; 1hi1001 \le h_i \le 100).

The supermarket has at most 7 carpets in total, that is iai7\sum_i a_i \le 7.

Output

Print yes if the room can be covered under the rules above, and no otherwise.