#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <ctime>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
const ll SIZE = 1000, INF = 1e9 * 1e9 + 2, MOD = 1e9 + 7;

bool edges[12][12];
pair<ll, ll> dsu[30][30];

pair<ll, ll> get(ll u, ll v) {
	if (dsu[u][v] == make_pair(u, v)) return { u, v };
	else return dsu[u][v] = get(dsu[u][v].first, dsu[u][v].second);
}

void uni(pair<ll, ll> u, pair<ll, ll> v) {
	u = get(u.first, u.second);
	v = get(v.first, v.second);
	if (u != v) {
		dsu[u.first][u.second] = v;
	}
}

ll n, m;
ll stresses() {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) dsu[i][j] = { i, j };
	}

	set<tuple<ll, ll, ll, ll>> s;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int i1 = 0; i1 < n; i1++) {
				for (int j1 = 0; j1 < n; j1++) {
					if (edges[i][i1] && edges[j][j1] && s.find({ i, j, i1, j1 }) == s.end()) {
						uni({ i, j }, { i1, j1 });
						s.insert({ i, j, i1, j1 });
						//cout << ((i + 1) * 10 + j + 1) << " " << ((i1 + 1) * 10 + j1 + 1) << "\n";
					}
				}
			}
		}
	}

	set<pair<ll, ll>> st;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) st.insert(get(i, j));
	}

	return st.size();
}

vector<vector<ll>> gr;

void input() {
	cin >> n >> m;
	
	gr.resize(n);
	for (int i = 0; i < m; i++) {
		ll u, v;
		cin >> u >> v;
		u--; v--;
		gr[u].push_back(v);
		gr[v].push_back(u);
		//edges[u][v] = 1;
		//edges[v][u] = 1;
	}
}

vector<pair<ll, ll>> eds;
void rand_test() {
	n = rand() % 10 + 1, m = rand() % 50 + 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			edges[i][j] = 0;
		}
	}

	gr.clear();
	gr.resize(n);
	eds.clear();
	for (int i = 0; i < m; i++) {
		ll u = rand() % n, v = rand() % n;
		if (!edges[u][v] && u != v) {
			edges[u][v] = 1;
			edges[v][u] = 1;
			eds.push_back({ u, v });
			gr[u].push_back(v);
			gr[v].push_back(u);
		}
	}
}
ll cur = 0;
bool fl = false;
vector<bool> used;
vector<ll> col;

void dfs(int v) {
	used[v] = 1;

	cur++;
	for (auto to : gr[v]) {
		if (!used[to]) {
			col[to] = !col[v];
			dfs(to);
		}
		else if (col[to] == col[v]) fl = true;
	}
}
ll sol() {
	used.clear();
	used.resize(n);
	col.clear();
	col.resize(n);

	ll ans = 0, t = 0, t2 = 0, ns = 0, vis = 0;
	for (int i = 0; i < n; i++) {
		if (!used[i]) {
			fl = false;
			cur = 0;
			dfs(i);
			if (cur == 1) {
				ans += vis * 2 + 1;
				ns++;
			}
			else {
				ll vl = 0;
				if (fl) {
					vl += 2 * t + ns * 2 * cur;
				}
				else {
					vl += (4 * t2) + (t - t2) * 2 + ns * 2 * cur;
				}
				ans += vl + (1 + !fl);

				t += 1;
				if (!fl) t2++;
			}
			vis += cur;
		}
	}

	return ans;
}

int main() {
	fastInp;
	
	ll t = 1;
	while (t--) {
		/*rand_test();
		ll q = sol(), q2 = stresses();
		if (q != q2) {
			cout << gr.size() << " " << eds.size() << "\n";
			for (auto cur : eds) cout << cur.first << " " << cur.second << "\n";
			cout << q << " " << q2 << "\n";
			cout << "";
		}*/
		
		input();
		cout << sol() << "\n";
		
	}

	
	return 0;
}

Measured memory_bytes: 15344