Universal Cup Judging System

Universal Cup

Time Limit: 12.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

Description

The New Year holidays are over, and your construction company is getting back to work. Unfortunately, some employees are still celebrating...

Today, $a$ sober and $b$ drunk workers came to work for you. Each worker will be available for the whole day. Your company also received $m$ orders for today. Each order is specified by the start and the end of the time span to perform it: $[st, fn]$. Such an order requires a single worker to work on it from moment $st$ to moment $fn$, inclusive. A worker can complete multiple orders if their time spans do not intersect. Additionally, each order has one of the two types: a simple order can be completed by any worker, while a complex order requires a sober worker.

Will your company be able to handle today's orders?

Input

The first line contains an integer $t$, the number of test cases ($1 \le t \le 2000$). For each test case:

The first line contains three integers: $a$, $b$, and $m$ ($0 \le a, b, m \le 10\,000$).

Then $m$ lines follow. Each line contains three integers, $type$, $st$, and $fn$, describing a simple (if $type = 1$) or complex ($type = 2$) order with the time span $[st, fn]$ ($type \in \{1, 2\}$; $1 \le st \le fn \le 2 \cdot m$). For example, a line 1 2 4 describes a simple order which requires three moments, from second to fourth, both ends included.

The sum of $m$ over all test cases is at most $10\,000$.

Output

For each test case, print a single line with the answer: "Yes" or "No" (case-insensitive).

Example

1
1 1 2
1 1 2
2 2 4
Yes

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1224EditorialOpen题解jianglyView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.