#include<bits/stdc++.h>
using namespace std;
#define gc getchar
#define pc putchar
#define ll long long
#define ull unsigned ll
int read(){
	int ret=0;bool f=1;char c=gc();
	while(!isdigit(c))(c=='-'?f=!f:0),c=gc();
	while(isdigit(c))ret=(ret<<3)+(ret<<1)+(c^48),c=gc();
	return f?ret:-ret;
}
const int mod=1e9+7;
const int maxe=2e6+5,maxn=5e5+5;
int n,m;
struct node{int u,v;}e[maxe>>1];
int lnk[maxn],nxt[maxe],son[maxe],tot;
void add_e(int u,int v){son[++tot]=v,nxt[tot]=lnk[u],lnk[u]=tot;}
ull ans;
int fa[maxn],dep[maxn],siz[maxn],siz_e[maxn];
void dfs(int u){
	siz[u]=1;
	for(int j=lnk[u];j;j=nxt[j])if(!dep[son[j]])siz_e[u]++,dep[son[j]]=dep[u]+1,fa[son[j]]=u,dfs(son[j]),siz[u]+=siz[son[j]],siz_e[u]+=siz_e[son[j]];
}
ull qpow(ull x,int y){
	ull ret=1;
	while(y){
		if(y&1)ret=ret*x%mod;
		x=x*x%mod,y>>=1;
	}
	return ret;
}
ull C(int n,int m){
	ull ret=1;if(m<n-m)m=n-m;
	for(int i=m+1;i<=n;i++)ret=ret*i;
	for(int i=1;i<=n-m;i++)ret=ret/i;
	return ret%mod;
}
int main(){
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	n=read(),m=read();
	for(int i=1,u,v;i<=m;i++)u=read(),v=read(),add_e(u,v),add_e(v,u),e[i]=(node){u,v};
	if(n-1==m){
		bool flg=1;
		for(int i=1;i<=m;i++)if(min(e[i].u,e[i].v)!=i||max(e[i].u,e[i].v)!=i+1){flg=0;break;}
		if(flg){
			ans=qpow(2,n-1)*n%mod;
			for(int k=2;k<=n;k++)
			for(int l=1;l<=n-k+1;l++)
			for(int r=l+k-1;r<=n;r++){
				ans=(ans+C(r-l+1,k)*qpow(2,l-1+n-r)%mod)%mod;
			}
			return cout<<ans<<endl,0;
		}
		fa[1]=1;dep[1]=1;
		dfs(1);
		ans=(1ull*n*(m+1)+1)%mod;
		return cout<<ans<<endl,0;
	}
	ans=(1ull*n*(m+1)+1)%mod;
	cout<<ans<<endl;
	return 0;
}