#agc011c. [agc011_c]Squared Graph
[agc011_c]Squared Graph
Problem Statement
Takahashi has received an undirected graph with vertices, numbered , , ..., . The edges in this graph are represented by . There are no self-loops and multiple edges in this graph.
Based on this graph, Takahashi is now constructing a new graph with vertices, where each vertex is labeled with a pair of integers (, ). The edges in this new graph are generated by the following rule:
- Span an edge between vertices and if and only if both of the following two edges exist in the original graph: an edge between vertices and , and an edge between vertices and .
How many connected components are there in this new graph?
Constraints
- There exists no pair of distinct integers and such that and .
Input
The input is given from Standard Input in the following format:
:
Output
Print the number of the connected components in the graph constructed by Takahashi.
Sample Input 1
3 1
1 2
Sample Output 1
7
The graph constructed by Takahashi is as follows.
Sample Input 2
7 5
1 2
3 4
3 5
4 5
2 6
Sample Output 2
18