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: Accepted)

/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
/*#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <assert.h>*/

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

ll n, m, cnt, sz[N], col[N];
bool u[N], bad[N];
vector < ll > g[N];

void dfs(ll v) {
    u[v] = 1;
    sz[cnt]++;
    for (auto to : g[v]) {
        if (!u[to]) {
            col[to] = col[v] ^ 1;
            dfs(to);
        }
        if (col[to] == col[v]) bad[cnt] = 1;
    }
}

int main() {
	ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

    cin >> n >> m;
    forn(i, 1, m) {
        ll x, y;
        cin >> x >> y;
        g[x].eb(y);
        g[y].eb(x);
    }

    forn(i, 1, n) {
        if (!u[i]) {
            ++cnt;
            dfs(i);
        }
    }

    ll ans = 1ll * n * n, sum = 0, c = 0, b = 1;
    forn(i, 1, cnt) {
        if (sz[i] == 1) continue;
        ans -= 1ll * sz[i] * sum * 2 + 1ll * sz[i] * sz[i];
        sum += sz[i];
        if (bad[i]) {
            ans += 1ll * 2 * (b - 1) + 1;
        }
        else {
            ans += 1ll * (b - c - 1) * 2 + 1ll * c * 4 + 2;
            ++c;
        }
        ++b;
    }

    cout << ans << "\n";

	return 0;
}