#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>

using namespace std;
typedef long long LL;
const int maxn = 400005;

int ehead[maxn],ecnt;
struct edge {
	int u,v,next;
}edg[maxn];
void add(int u,int v) {
	edg[++ecnt]=(edge){u,v,ehead[u]};
	ehead[u]=ecnt;
	edg[++ecnt]=(edge){v,u,ehead[v]};
	ehead[v]=ecnt;
}

int n,m,col[maxn],com,bir,siz,sing;LL ans;bool tag;
void dfs(int u) {
	siz++;
	for (int v,j=ehead[u];j;j=edg[j].next)
	if (col[v=edg[j].v]<0) col[v]=col[u]^1,dfs(v);
	else if (col[v]!=col[u]^1) tag=false;
}
int main()
{
	#ifdef Amberframe
		freopen("agc011c.in","r",stdin);
		freopen("agc011c.out","w",stdout);
	#endif
	memset(col,-1,sizeof col);
	scanf("%d %d",&n,&m);
	for (int u,v,i=1;i<=m;i++)
		scanf("%d %d",&u,&v),add(u,v);
	for (int i=1;i<=n;i++)
	if (col[i]<0) {
		col[i]=0;tag=true;siz=0;dfs(i);
		siz>1?(bir+=tag,com++):(sing++);
	}
	ans+=(LL)com*com+(LL)bir*bir+(LL)sing*sing+(LL)sing*(n-sing)*2;
	printf("%lld\n",ans);
	return 0;
}