//I LOVE CCF !!!   PLEASE LET ME PASS !!!! 
#include<iostream>
#include<cstdio>
using namespace std;
const int MAXN=2000005,MOD=1e9+7;
int n,m,head[MAXN],nxt[MAXN],to[MAXN],tot;
//I LOVE CCF !!!   PLEASE LET ME PASS !!!! 
void addEdge(int u,int v){
	nxt[tot]=head[u];
	to[tot]=v;
	head[u]=tot++;
}
//I LOVE CCF !!!   PLEASE LET ME PASS !!!! 
int main(){
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	scanf("%d%d",&n,&m);
//I LOVE CCF !!!   PLEASE LET ME PASS !!!! 
	for(int i=1;i<=n;i++)head[i]=-1;
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		addEdge(u,v);
		addEdge(v,u);
		int ans=0,last=1;
//I LOVE CCF !!!   PLEASE LET ME PASS !!!! 
		for(int i=1;i<=n;i++){
			if(n-i<=0)break;
			ans=ans+n*(n-i)/((i+1)*last)%MOD;
			ans%=MOD;
			last*=i+1;
		}
		cout<<(ans+n*2%MOD)%MOD;
	}
//I LOVE CCF !!!   PLEASE LET ME PASS !!!! 
	return 0;
}
//I LOVE CCF !!!   PLEASE LET ME PASS !!!! 