#include<bits/stdc++.h>
using namespace std;
#define LL long long
const LL mo=1e9+7;
LL n,m,ans=0;
string awa="awa";
int x,y;
LL road[5000][5000];
void guanggai(int city){
	if(city>n)return ;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			road[city][j]=min(road[city][j],road[city][i]+road[i][j]);
			road[j][city]=road[city][j];
		}
	}
	guanggai(city+1);
}
LL f(int from,int num){
	LL ansf=0;
	if(num<=1){
		for(int i=from+1;i<=n;i++)ansf+=road[from][i];
		return ansf;
	}
	for(int i=from+1;i<=n;i++){
		ansf+=f(i,num)+f(i,num-1);
	}
	return ansf;
}
int main(){
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	cin>>n>>m;
	if(n>=10000){
		cout<<n*m<<'\n';
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			road[i][j]=99999;
		}
	}
	for(int i=1;i<=n;i++)road[i][i]=0;
	for(int i=1;i<=m;i++){
		cin>>x>>y;
		road[x][y]=1;
		road[y][x]=1;
	}
	guanggai(1);
	ans=(n*(m+1))%mo;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=n-i;j++){
			ans=(ans+f(j,i))%mo;
		}
	}
	cout<<ans<<'\n';
}