#include<bits/stdc++.h>
//uh i think is Tarjan or make tree such as kruscal or prim
//if it's make tree i think is prim more but i hadn't write it before
//so I bai lan
// i can just use kruscal
// but this problem can't
//and i hadn't learn about tarjan before
//so , sorry
// I have to use random algorithm
// 0 pts expected
// why use English(Chinglish)? there's no Chinese shu ru fa
// next time CCF
// I love you CCF
using namespace std;
typedef long long ll;
const int N=1e5+10;
ll ans;
int n,m;
vector<int>G[N];
ll mod=1e9+7;
inline ll read(){
	ll x=0;
	bool f=true;
	char ch=getchar();
	for(;!isdigit(ch);ch=getchar())
		if(ch=='-')f=false;
	for(;isdigit(ch);ch=getchar())
		x=(x<<1)+(x<<3)+ch-'0';
	return f?x:~(x-1);
}
int main(){
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		int u=read(),v=read();
		G[u].push_back(v);
		G[v].push_back(u);
		ans+=u*v;
		ans%=mod;
	}
	printf("%lld\n",ans%mod);
	return 0;
}