#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

ll N, M;
vector<int> to[100010];
int idx[100010];
int edge[100010];
int node[100010];
int oe[100010];
int judge[100010];
int es[200010];
ll ans = 0;

void dfs(int v, int id, int type){
    idx[v] = id;
    node[id]++;
    oe[v] = type;
    for(auto u : to[v]){
        if(idx[u] != 0){
            if(oe[u] == type) judge[id] = true;
        }else{
            dfs(u, id, (type + 1) & 1);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M;
    ans = N * N;

    for(int i = 0; i < M; i++){
        int u, v;
        cin >> u >> v;
        es[i] = u;
        to[u].emplace_back(v);
        to[v].emplace_back(u);
    }

    int id = 1;
    for(int i = 1; i <= N; i++){
        if(idx[i] == 0) dfs(i, id++, 0);
    }
    for(int i = 0; i < M; i++){
        edge[idx[es[i]]]++;
    }
    ll nsum = 0, graph = 0, oc = 0;
    for(int i = 1; i < id; i++){
        if(node[i] == 1) continue;
        nsum += node[i];
        graph++;
        if(!judge[i]) oc++;
    }
    cout << ans - (nsum * nsum) + (graph * graph) + (oc * oc) << endl;
    return 0;
}
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=100010;
bool w[N],v[N];
int fa[N],sz[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline int find(int x,int &y) {
    if(fa[x]==x) return x;
    fa[x]=find(fa[x],y);
    return v[x]^=y,y=v[x],fa[x];
}
int main() {
    int n,m,A=0,B=0,C=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++) fa[i]=i,sz[i]=1;
    for(int i=1;i<=m;i++) {
	int X=0,Y=0,x=find(gi(),X),y=find(gi(),Y);
	if(x!=y) fa[x]=y,v[x]=X^Y^1,w[y]|=w[x],sz[y]+=sz[x];
	else w[x]|=X^Y^1;
    }
    for(int i=1;i<=n;i++)
	if(fa[i]==i) {
	    if(sz[i]==1) ++A;
	    else if(w[i]) ++B;
	    else ++C;
	}
    cout<<B+C+C+2LL*B*C+2LL*C*(C-1)+2LL*A*n-1LL*A*A+1LL*B*(B-1);
    return 0;
}