Bad Horse (Small2)
InterviewTime limit5sMemory limit512 MB
Decide whether members linked by troublesome pairs split into two groups with no pair inside one group.
Problem
Bad Horse leads the Evil League of Evil, and he has a lot of problems to deal with. Arguments and backstabbing inside the League have gotten out of hand, so Bad Horse decided to split the League into two departments and keep the troublesome members apart. Being the Thoroughbred of Sin, he is not about to spend his own valuable time working out how to split the members. That is what he has you, his loyal henchman, for.
You are given the list of troublesome pairs. Decide whether every member can be assigned to one of the two departments so that no department contains a troublesome pair. Only the members whose names appear in the input need an assignment.
Input
The first line contains the number of test cases . test cases follow.
Each test case starts with a line holding a positive integer , the number of troublesome pairs of League members. The next lines each contain a pair of names separated by a single space.
Limits
- Each member name consists of letters and the underscore character only.
- Names are case-sensitive.
- No pair appears more than once in the same test case.
- The two members of a pair are always different.
Output
For each test case, print one line of the form Case #x: y, where is the case number starting from 1, and is Yes if the members mentioned in the input can be split into two groups with neither group containing a troublesome pair, and No otherwise.