#include<bits/stdc++.h>
#define int long long
using namespace std;
//NOIP RP++
const int mod=1e9+7,N=1e5+10,M=1107;
int read(){
	int x=0,f=1;char c=getchar();
	while(c>'9'||c<'0'){
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c<='9'&&c>='0'){
		x=(x<<3)+(x<<1)+(c^48);
		c=getchar();
	}
	return x*f;
}
int C(int n,int m){
	int ans=0;
	for(int i=0;i<n;++i){
		ans=(ans+((n-i)*(n-i))%mod)%mod;
	}
	return ans;
}
signed main(){
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	int n=read(),m=read();
	for(int i=1;i<=n;++i){
		int a=read(),b=read();
	}
	printf("%lld\n",C(n,m));
	return 0;
}