SALE (Optional)
Practice
3.6 (149 votes)
Depth First search
Breadth First search
Easy Medium
Problem
55% Success 2868 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

There is a sale in the market on clothes , so as usual N girls gathered there to grab great deals.But due to huge popularity of sale crowd has gone uncontrollable. You being head of management team of the mall has been assigned the task to make them form a queue so that everyone can shop turn-wise. Since queue is going to be very long and knowing that its gonna take time for their turn there are M pair of girls who want to stand together in the queue so that they can discuss their personal stuff meanwhile. Now you need to make them form a queue so that none of them gets disappointed.

INPUT:

First line of input contains T number of test-cases , first line of each test-case contains two elements N , M total number of girls and number of pair of girls who wants to stand together. Next M line will contain pair of integers x y , which mean in queue they either stand as x y or y x .

OUTPUT:

For each test-case in a new line output "NO" ( without quotes ) if there is no possible arrangement such that no one gets disappointed if such a arrangement is possible print "YES" ( without quotes ) .

Constraints:

1 ≤ T ≤ 10

N , M ≤ 10 ^ 5

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
263 votes
Tags:
MathematicsApprovedEasy-Medium
Points:20
99 votes
Tags:
Ad-HocBasic MathEasy簡単MathematicsMathematics
Points:30
5 votes
Tags:
AlgorithmsApprovedDynamic ProgrammingMathMediumNumber TheoryOpenPrimality test