Problem: Count the number of strings S that satisfy the following constraints, modulo 10^9 + 7.

* The length of S is exactly N.
* S consists of digits (`0`...`9`).
* You are given Q intervals. For each i (1 \leq i \leq Q), the integer represented by S[l_i \ldots r_i] (the substring of S between the l_i-th (1-based) character and the r_i-th character, inclusive) must be a multiple of 9.



Here, the string S and its substrings may have leading zeroes. For example, `002019` represents the integer 2019.

Constraints

* 1 \leq N \leq 10^9
* 1 \leq Q \leq 15
* 1 \leq l_i \leq r_i \leq N

Input

Input is given from Standard Input in the following format:


N
Q
l_1 r_1
:
l_Q r_Q


Output

Print the number of strings that satisfy the conditions, modulo 10^9 + 7.

Examples

Input

4
2
1 2
2 4


Output

136


Input

6
3
2 5
3 5
1 3


Output

2720


Input

20
10
2 15
5 6
1 12
7 9
2 17
5 15
2 4
16 17
2 12
8 17


Output

862268030

Solution (in CPP):

Solution:
#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007

int n, q, l, r, hv = 1, par[105], id[105], at[105], x[105], fm, im;
vector<int> gp;
pair<int, int> p[105];
int u;
long long inv9, ans, mul[105], mu, smu, dp[10][1 << 16], sum;

int find(int a) {
	return par[a] == a ? a : par[a] = find(par[a]);
}

long long po(long long b, int pp) {
	long long re = 1;
	while (pp) {
		if (pp & 1)
			re = re * b % MOD;
		b = b * b % MOD;
		pp >>= 1;
	}
	return re;
}

int main() {
	inv9 = po(9, MOD - 2);
	scanf("%d%d", &n, &q);
	for (int i = 0; i < q; i++) {
		scanf("%d%d", &l, &r);
		p[i * 2] = {l - 1, i * 2};
		p[i * 2 + 1] = {r, i * 2 + 1};
	}
	sort(p, p + q * 2 + 1);
	for (int i = 1; i <= q * 2; i++) {
		if (p[i].first != p[i - 1].first) {
			x[hv] = p[i].first;
			par[hv] = hv;
			hv++;
		}
		at[p[i].second] = hv - 1;
	}
	for (int i = 0; i < q; i++)
		if (find(at[i * 2]) != find(at[i * 2 + 1]))
			par[par[at[i * 2]]] = par[at[i * 2 + 1]];
	memset(id, -1, sizeof(id[0]) * hv);
	gp.reserve(hv);
	for (int i = 0; i < hv; i++) {
		if (id[find(i)] == -1) {
			id[par[i]] = gp.size();
			gp.push_back(0);
		}
		gp[id[par[i]]] |= 1 << i;
	}
	ans = po(10, n - x[hv - 1]);
	for (int i = 1; i < hv; i++) {
		mul[i] = (po(10, x[i] - x[i - 1]) + MOD - 1) * inv9 % MOD;
		ans = ans * mul[i] % MOD;
		mul[i] = (mul[i] + 1) * po(mul[i], MOD - 2) % MOD;
	}
	dp[9][0] = 1;
	fm = (1 << gp.size()) - 1;
	for (int i = 1; i <= fm; i++) {
		mu = 1;
		u = 0;
		for (int j = 0; j < gp.size(); j++)
			if (i & (1 << j))
				u |= gp[j];
		for (int j = 1, bm = 3; j < hv; j++, bm <<= 1)
			if ((u & bm) == bm)
				mu = mu * mul[j] % MOD;
		im = i ^ fm;
		for (int j = 1; j <= 9; j++) {
			smu = mu * (j == 9 ? 1 : j) % MOD;
			if (dp[j][0])
				dp[j - 1][i] = (dp[j - 1][i] + dp[j][0] * smu) % MOD;
			for (int k = im; k; k = (k - 1) & im)
				if (dp[j][k])
					dp[j - 1][i | k] = (dp[j - 1][i | k] + dp[j][k] * smu) % MOD;
		}
	}
	for (int i = 0; i < 9; i++)
		sum += dp[i][fm];
	printf("%lld\n", ans * sum % MOD);
}