eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Bi-coloring

Bi-coloring

Given a graph determine how many ways you can color the graph with at most two colors. There cannot be an edge containing two vertices of the same color. \InputFile First line of the input contains \textbf{T} the number of test cases. Each test case starts with a line containing two integers \textbf{V} (\textbf{1 }≤ \textbf{V} ≤ \textbf{30}) and \textbf{E} (\textbf{0} ≤ \textbf{E} ≤ \textbf{1000}). Each of the next \textbf{E} line contains two integers \textbf{a}, \textbf{b} (\textbf{0} ≤ \textbf{a} ≤ \textbf{V-1}, \textbf{0} ≤ \textbf{b} ≤ \textbf{V-1}) denoting that there is a bidirectional edge between \textbf{a} and \textbf{b}. There will not be any self loop or duplicate edges. The last line of the input will be a blank. \OutputFile For each test case, output the number of ways you can color the graph with only two colors. If you cannot color the graph with at most two colors output \textbf{-1}.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
4
5 5
0 1
0 4
1 2
2 3
3 0

3 3
0 1
1 2
2 0

6 7
0 1
1 2
2 3
3 0
4 0
4 5
5 1

2 0
Вихідні дані #1
2
-1
2
4
Джерело ACM-ICPC Malaysia al-Khawārizmī Programming Contest 2011