Polycarp got the accompanying issue: given a framework piece of size 2×n, a few cells of it are obstructed. You want to check in case it is feasible to tile all free cells utilizing the 2×1 and 1×2 tiles (dominoes).    For instance, if

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 24PE
icon
Related questions
Question

Correct answer will be upvoted else Multiple Downvoted. Computer science.

 

 

Polycarp got the accompanying issue: given a framework piece of size 2×n, a few cells of it are obstructed. You want to check in case it is feasible to tile all free cells utilizing the 2×1 and 1×2 tiles (dominoes). 

 

For instance, if n=5 and the strip appears as though this (dark cells are obstructed) 

 

Polycarp handily tackled this errand and accepted his New Year's gift. Would you be able to settle it? 

 

Input 

 

The main line contains an integer t (1≤t≤104) — the number of experiments. Then, at that point, t experiments follow. 

 

Each experiment is gone before by a vacant line. 

 

The main line of each experiment contains two integers n and m (1≤n≤109, 1≤m≤2⋅105) — the length of the strip and the number of impeded cells on it. 

 

Every one of the following m lines contains two integers ri,ci (1≤ri≤2,1≤ci≤n) — numbers of lines and sections of hindered cells. It is ensured that all impeded cells are unique, for example (ri,ci)≠(rj,cj),i≠j. 

 

It is ensured that the amount of m over all experiments doesn't surpass 2⋅105. 

 

Output 

 

For each experiment, print on a different line: 

 

"Indeed", in case it is feasible to tile all unblocked squares with the 2×1 and 1×2 tiles; 

 

"NO" in any case. 

 

You can output "YES" and "NO" regardless (for instance, the strings yEs, indeed, Yes and YES will be perceived as certain).

 

 

 

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Topological Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning