#include <bits/stdc++.h>
using namespace std;
long long n,m;
const int mod = 1e9 + 7;
int main() {
	freopen("barrack.in", "r", stdin);
	freopen("barrack.out", "w", stdout);
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int v,t;
		cin >> v >> t;
	}
	long long ans = (n * n + 1) % mod;
	cout << ans << endl;
	return 0;
}
