Problem:
Score : 800 points

Problem Statement

Takahashi has received an undirected graph with N vertices, numbered 1, 2, ..., N.
The edges in this graph are represented by (u_i, v_i).
There are no self-loops and multiple edges in this graph.

Based on this graph, Takahashi is now constructing a new graph with N^2 vertices, where each vertex is labeled with a pair of integers (a, b) (1 \leq a \leq N, 1 \leq b \leq N).
The edges in this new graph are generated by the following rule:

Span an edge between vertices (a, b) and (a', b') if and only if both of the following two edges exist in the original graph: an edge between vertices a and a', and an edge between vertices b and b'.

How many connected components are there in this new graph?

Constraints

2 \leq N \leq 100,000

0 \leq M \leq 200,000

1 \leq u_i < v_i \leq N

There exists no pair of distinct integers i and j such that u_i = u_j and v_i = v_j.

Input

The input is given from Standard Input in the following format:

N M
u_1 v_1
u_2 v_2
:
u_M v_M

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

Solution in C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Yulian
 */

#include <iostream>
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>


#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>


class DisjointUnionSets {
private:
  std::vector<int> parent;
  std::vector<int> rank;
  int num;
public:
  DisjointUnionSets(unsigned int n) {
    num = n;
    parent = std::vector<int>(n);
    for (unsigned int i = 0; i < n; ++i) {
      parent[i] = i;
    }
    rank = std::vector<int>(n);
  }

  int find(int i) {
    int res;
    if (parent[i] == i) {
      res = i;
    } else {
      res = find(parent[i]);
      parent[i] = res;
    }
    return res;
  }

  void unite(int i, int j) {
    int irep, jrep, irank, jrank;
    irep = find(i);
    jrep = find(j);
    if (jrep != irep) {
      --num;
      irank = rank[irep];
      jrank = rank[jrep];
      if (irank < jrank) {
        parent[irep] = jrep;
      } else {
        parent[jrep] = irep;
        if (irank == jrank) {
          ++rank[irep];
        }
      }
    }
  }

  int size() const{
    return num;
  }
};


using namespace std;
class C {
public:
	void solve(std::istream& in, std::ostream& out) {
    ios::sync_with_stdio(false);
    int n, m, u, v;
    in >> n >> m;
//    vector<vector<int>> a(n);
    DisjointUnionSets d (n * n);
    for(int i = 0; i < m; ++i){
      in >> u >> v;
      --u;
      --v;

      d.unite(u % n + u * n, v % n + v * n);
      d.unite(v % n + u * n, u % n + v * n);
      d.unite(u % n + v * n, v % n + u * n);
    }
    out << d.size() << endl;



	}
};


int main() {
	C solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}