#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const ll MOD = 1e9 + 7;

ll powmod(ll a, ll b) {
	ll r = 1;
	while (b) {
		if (b & 1) {
			r = r * a % MOD;
		}
		a = a * a % MOD;
		b /= 2;
	}
	return r;
}

const int MAXQ = 16;
int N, Q;
int adj[MAXQ];

vector<pair<int, ll>> extra[MAXQ];
ll coeff[1 << MAXQ];
ll dp[2][1 << MAXQ];

const ll i9 = powmod(9, MOD - 2);

int main() {
	vector<pair<int, int>> pts = {{0, 0}};
	scanf("%d %d", &N, &Q); Q++;
	for (int i = 1; i < Q; i++) {
		int l, r; scanf("%d %d", &l, &r); l--;
		pts.emplace_back(l, i);
		pts.emplace_back(r, i);
	}

	sort(pts.begin(), pts.end());
	ll ans = powmod(10, N - pts.back().first);

	for (size_t i = 0; i + 1 < pts.size(); i++) {
		int x = pts[i].second;
		int y = pts[i + 1].second;
		if (pts[i].first == pts[i + 1].first) {
			adj[x] |= 1 << y;
			adj[y] |= 1 << x;
		} else {
			ll base = i9 * (powmod(10, pts[i + 1].first - pts[i].first) - 1) % MOD;
			ans *= base;
			ans %= MOD;
			base = (base + 1) * powmod(base, MOD - 2) % MOD;
			extra[x].emplace_back(y, base);
		}
	}

	for (int m = 0; m < (1 << Q); m++) {
		coeff[m] = 1;
		for (int i = 0; i < Q; i++) {
			if (!(m & (1 << i))) continue;
			if ((adj[i] & m) != adj[i]) {
				coeff[m] = 0;
				break;
			}
			for (auto p : extra[i]) {
				if (m & (1 << p.first)) {
					coeff[m] *= p.second;
					coeff[m] %= MOD;
				}
			}
		}
	}

	int cur = 0, nxt = 1;
	dp[0][0] = 1;
	for (int x = 0; x < 9; x++, swap(cur, nxt)) {
		memset(dp[nxt], 0, sizeof(ll) * (1 << Q));
		
		for (int m = 0; m < (1 << Q); m++) {
			int cm = (1 << Q) - 1 - m;
			for (int s = cm; ; s = (s - 1) & cm) {
				if ((s & 1) || x) {
					dp[nxt][s | m] += dp[cur][m] * coeff[s];
					dp[nxt][s | m] %= MOD;
				}
				if (s == 0) break;
			}
		}
	}
	ans *= dp[cur][(1 << Q) - 1];
	ans %= MOD;

	printf("%lld\n", ans);

	return 0;
}