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<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint qinv=111111112;
llint cul(int keta){
	llint ans=1;
	llint bgen=10;
	for(int h=0;h<30;h++){
		if(keta&(1<<h)){ans*=bgen;ans%=mod;}
		bgen*=bgen;bgen%=mod;
	}
	ans--;
	ans*=qinv;ans%=mod;
	return ans;
}
int main(void){
	int n,Q,i,j;cin>>n>>Q;
	vector<pair<int,int>>bas;
	for(i=0;i<Q;i++){
		int L,R;cin>>L>>R;
		bas.pub(mp(L-1,i));
		bas.pub(mp(R,i));
	}
	SO(bas);
	//区間 numberを求める
	vector<llint>kak(Q+Q-1);
	for(i=0;i<Q+Q-1;i++){kak[i]=cul(bas[i+1].fir-bas[i].fir);}
	static llint dp[32768][10]={0};
	dp[0][0]=1;
	
	for(int bi=0;bi<(1<<Q);bi++){
		//biにする
		int ko=1;//ko=0は遷移順を最後にする
		while(ko<(1<<Q)){
			if(ko-(bi&ko)!=0){ko+=ko-(bi&ko);continue;}
			//cerr<<"bi="<<bi<<"ko="<<ko<<endl;
			//bi-koにkoの内容を加える
			llint bai=1;
			for(i=0;i<Q+Q-1;i++){
				int aaa=0,bbb=0;
				if((ko&(1<<bas[i].sec))>0){aaa=2;}
				else if((bi&(1<<bas[i].sec))>0){aaa=1;}
				if((ko&(1<<bas[i+1].sec))>0){bbb=2;}
				else if((bi&(1<<bas[i+1].sec))>0){bbb=1;}
				if(aaa+bbb==4){bai*=kak[i]+1;bai%=mod;}
				else if(aaa+bbb==3){bai*=kak[i];bai%=mod;}
			}
			for(int su=0;su<9;su++){dp[bi][su+1]+=bai*dp[bi-ko][su];dp[bi][su+1]%=mod;}
			ko++;
		}
		for(int su=0;su<9;su++){dp[bi][su+1]+=dp[bi][su];dp[bi][su+1]%=mod;}
		//cerr<<"bi="<<bi<<endl;
		//for(int su=0;su<=9;su++){cerr<<"dp="<<dp[bi][su]<<endl;}
	}
	
	llint ans=dp[(1<<Q)-1][9]*qinv%mod;
	int nko=n-bas.back().fir+bas[0].fir;
	ans*=(cul(nko)*9+1)%mod;ans%=mod;
	cout<<ans<<endl;
	return 0;
}