Under construction

Still being built. Things may change

Furniture Factory

Time limit2sMemory limit128 MB

Summary
Decide if m workers can finish n preemptible jobs with release times and deadlines when each job takes at most one worker at a time.
Level

Medium7 of 10

Topics
Graph, Intervals
Solved
No attempts yet

Problem

A furniture factory employs mm workers in total. Every worker has exactly the same skill and productivity. Next month the factory must build nn pieces of furniture, and each piece ii comes with three values.

  • sis_i: the earliest time at which work on it may begin
  • wiw_i: the total amount of work needed to finish it
  • did_i: the deadline by which it must be finished (di≥si+wid_i \ge s_i + w_i)

In other words, piece ii can only be worked on from time sis_i onward, it is complete once wiw_i units of work have been spent on it, and it must be finished no later than time did_i.

At any moment at most one worker may work on a given piece of furniture. Work may be paused and resumed later, and a paused piece may be picked up by a different worker. Every worker starts and stops on integer times, and time is written as 1,2,3,…,max⁡{di}1, 2, 3, \dots, \max\{d_i\} for convenience.

Determine whether a production plan exists that finishes every piece of furniture by its own deadline.

Input

The first line contains the number of test cases TT. For each test case, the first line contains the number of workers mm and the number of pieces nn (1≤m≤101 \le m \le 10, 1≤n≤1001 \le n \le 100). The next nn lines each contain sis_i, wiw_i, did_i for one piece (1≤si<di≤5001 \le s_i < d_i \le 500, 1≤wi≤di−si1 \le w_i \le d_i - s_i).

Output

For each test case, print one line: Yes if a production plan finishes every piece of furniture by its deadline, and No otherwise.

Examples3

  1. Example 1

    Input
    2
    2 4
    2 2 5
    1 5 8
    4 2 6
    3 3 7
    1 3
    2 4 7
    3 1 5
    4 2 6
    
    Expected output
    Yes
    No
    
  2. Example 2

    Input
    1
    1 1
    1 3 5
    
    Expected output
    Yes
    
  3. Example 3

    Input
    1
    1 2
    1 1 2
    1 1 2
    
    Expected output
    No