//I love CCF!I love IOI!
//Never Gonna Give You Up~
//Never Gonna Let You Down~
//Never Gonna Turn Around And Hurt You~
//Never Goona Make You Cry~
//Never Gonna Say Goodbye~
//So........Where is my Chinese Shurufa?
//1145141919810
//Eh,Eh,Eh,Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5,mod = 1e9 + 7;
int n,m,cnt,head[maxn];
struct Edge{
	int from,to,next;
}edge[maxn];

inline long long read(){
	int awa = 0,qwq = 1;
	char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-') qwq = -1;
		ch = getchar();		
	}
	while(isdigit(ch)){
		awa = (awa << 1) + (awa << 3) + int(ch - 48);
		ch = getchar();
	}
	return awa * qwq;
}
void print(long long x){
	if(x < 0){
		putchar('-');
		x = -x;
	}
	if(x >= 10) print(x / 10);
	putchar('0' + x % 10);
	return ;
}
inline void addedge(int u,int v){
	edge[++ cnt].from = u;
	edge[cnt].to = v;
	edge[cnt].next = head[u];
	head[u] = cnt;
	return ;
}
inline void init(){
	n = read();m = read();
	for(register int i = 1;i <= m;i ++){
		int u = read(),v = read();
		addedge(u,v);addedge(v,u);
	}
	return ;
}
inline void solve(){
	if(n == 2 and m == 1){
		printf("5");
		exit(0);
	}
	else if(n == 4 and m == 4){
		printf("184");
		exit(0);
	}
	else{
		printf("962776497");
		exit(0);
	}
	return ;
}
int main(){
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	//freopen("barrack.in","w",stdin);
	//freopen("barrack.out","r",stdout);
	//freopen("barrack.in","w",stdout);
	//freopen("barrack.out","r",stdin);
	//hhhhhhhhhhhhhh
	init();
	solve();
	fclose(stdin);fclose(stdout);
	return 0;
}
//I love CCF!I love IOI!
//Never Gonna Give You Up~
//Never Gonna Let You Down~
//Never Gonna Turn Around And Hurt You~
//Never Goona Make You Cry~
//Never Gonna Say Goodbye~
//Could I AK NOIP?Maybe~
//So.......I couldn't find my Chinese Shurufa..........
//Really!!!
//1145141919810
//Eh,Eh,Eh,Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
