Man in the Middle
InterviewTime limit3sMemory limit256 MB
Decide whether removing some single person disconnects the connected friendship network.
Problem
In a connected social network, a Man in the Middle is a person whose departure disconnects the network. Report whether any such person exists.
Input
The first line contains test cases (). Each test case gives , , and friendship pairs.
Output
Print YES if the network has a Man in the Middle, otherwise print NO.