Submeter | Todas submissőes | Melhores | Voltar |
Problem hidden
TRUETWIN - Finding true twins |
In every university there is a group of N students that like to run parties, and there are M friendships among the students. Friendship among the students is reciprocal: if A is friend with B then B is also friend with A. Hence the pairs A,B and B,A count as a single friendship. Every Saturday evening one of the students would invite all his/her friends to his home. At some universities it was observed that there are two students A, B which are always invited together or not invited at all at every party run by the other students. Such students are called twins. When the twins are friends they are called true twins and when they are not friends they are called false twins.
Input
The first line of the input contains an integer T – the amount of test cases. Then T test descriptions follow. The first line of each test consists of two integers N and M separated with a space. Then M lines follow, each containing two integers A and B separated with a space, describing friendships. No testcase will contain twice the same friendship A, B.
The limits are 1≤T≤10, 1≤N≤10000, 0≤M≤100050, 1≤A<B≤N.
Output
For each test case, output a line
Case #X: Y
where X is the test case number, starting from 1, and Y is either the string "No twins" without the quotes if there are no true twins, otherwise it is the string "A B" where A, B is the lexicographical smallest true twin pair.
Example
Input: 2
6 8
1 2
1 4
1 5
2 3
2 4
3 4
3 6
5 6
6 7
1 2
1 4
1 5
2 3
3 4
3 6
5 6 Output: Case #1: 2 4
Case #2: No twins
Adicionado por: | xtof |
Data: | 2016-10-12 |
Tempo limite: | 1s-20s |
Tamanho do fonte: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Linguagem permitida: | Todas exceto: ASM64 CLOJURE ERL FSHARP GOSU PERL6 PY_NBC SCALA TCL |