// IF I CANNOT GET THIS CODE ACCEPTED
// I WILL EAT 2019GZ03'S HEAD
// JUE DUI BU ZHEN XIANG
#include <bits/stdc++.h>
using namespace std;
#define il inline
#define elif else if

// Type
#define ld double
#define ll long long
#define ull unsigned ll

// Vector
#define vc vector
#define Pb push_back
#define Pf push_front
#define Eb emplace_back
#define All(x) x.begin(),x.end()
#define AllRev(x) x.rbegin(),x.rend()

// Memory
#define Ms(_data) memset(_data,0,sizeof(_data))
#define Msn(_data,_num) memset(_data,_num,sizeof(_data))

// Template
#define _cl class
#define _tp template
#define _tyn typename

// Pair
#define Mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>

// Loop
#define For(i,j) for( int (i) = 1 ; (i) <= (j) ; ++(i) )
#define For0(i,j) for( int (i) = 0 ; (i) < (j) ; ++(i) )
#define Forx(i,j,k) for( int (i) = (j) ; (i) <= (k) ; ++(i) )
#define Forstep(i,j,k,st) for( int (i) = (j) ; (i) <= (k) ; (i) += (st) )
#define fOR(i,j) for( int (i) = (j) ; (i) >= 1 ; --(i) )
#define fOR0(i,j) for( int (i) = (j)-1 ; (i) >= 0 ; --(i) )
#define fORx(i,j,k) for( int (i) = (k) ; (i) >= (j) ; --(i) )

// Read
struct InputReader{
	#define bs 1048576
	char buf[bs]; int p;
	il InputReader(){ p = bs; }
	il void Flush(){ p = 0; fread(buf,1,bs,stdin); }
	il char C(){ if(p >= bs) Flush(); return buf[p++]; }
	il char Readnum(){ char ch = C(); while( !isdigit(ch) && ch != '-' ) ch = C(); return ch; }
	il void Readalpha( char &c ){ c = C(); while( !isalpha(c) ) c = C(); }
	int operator() (){
		int ans = 0, fu = 1; char ch = Readnum();
		if( ch == '-' ) fu = -1, ch = C();
		while( ch >= '0' && ch <= '9' ){
			ans = ans*10 + ch-'0';
			ch = C();
		}
		return ans * fu;
	}
	ll Readll(){
		ll ans = 0LL, fu = 1LL; char ch = Readnum();
		if( ch == '-' ) fu = -1LL, ch = C();
		while( ch >= '0' && ch <= '9' ){
			ans = ans*10LL + ch-'0';
			ch = C();
		}
		return ans * fu;
	}
	il void Readstring( string &x ){
		x.clear(); char ch = C();
		while( !isdigit(ch)  &&  !isalpha(ch)  &&  ch != '#'  &&  ch != '.' ) ch = C();
		while( isdigit(ch)  ||  isalpha(ch)  ||  ch == '#'  ||  ch == '.' ){
			x += ch;
			ch = C();
		}
	}
	il void Readchstring( char s[] ){
		int len = 0; char ch = C();
		while( !isdigit(ch)  &&  !isalpha(ch)  /*&&  ch != '*'  &&  ch != '?'*/ ) ch = C();
		while( isdigit(ch)  ||  isalpha(ch)  /*||  ch == '*'  ||  ch == '?'*/ ){
			s[len++] = ch;
			ch = C();
		}
		s[len] = '\0';
	}
	il void Specialread( char &c ){
		c = C();
		while( !isdigit(c) && !isalpha(c) && c != '#'  &&  c != '.'  &&  c != '='  &&  c != 'B' ) c = C();
	}
	#undef bs
}In;
il void Read( int &x ){ x = In(); }
il void Read( int &x, int &y ){ x = In(); y = In(); }
il void Read( int &x1 , int &x2 , int &x3 ){ x1 = In(); x2 = In(); x3 = In(); }
il void Read( int &x1 , int &x2 , int &x3 , int &x4 ){ x1 = In(); x2 = In(); x3 = In(); x4 = In(); }
il void Read( ll &x ){ x = In.Readll(); }
il void Read( ll &x, ll &y ){ x = In.Readll(); y = In.Readll(); }
il void Read( ll &x1 , ll &x2 , ll &x3 ){ x1 = In.Readll(); x2 = In.Readll(); x3 = In.Readll(); }
il void Read( ll &x1 , ll &x2 , ll &x3 , ll &x4 ){ x1 = In.Readll(); x2 = In.Readll(); x3 = In.Readll(); x4 = In.Readll(); }
_tp<_tyn T> void Read( T a[] , int st , int ed ){ Forx(i,st,ed) Read(a[i]); }
#define iRead(k) int k; Read(k);
#define iRead2(a,b) iRead(a); iRead(b);
#define iRead3(a,b,c) iRead2(a,b); iRead(c);
#define iRead4(a,b,c,d) iRead2(a,b); iRead2(c,d);
#define lRead(k) ll k; Read(k);
#define lRead2(a,b) lRead(a); lRead(b);
#define lRead3(a,b,c) lRead2(a,b); lRead(c);
#define lRead4(a,b,c,d) lRead2(a,b); lRead2(c,d);

// File
#define Fin(a) freopen(a,"r",stdin)
#define Fout(a) freopen(a,"w",stdout)
il void FILEIO(){
	#ifdef intLSY
		Fin("in.in");
	#endif
}
il void FILEIO( string pname ){
	#ifndef intLSY
		Fin((pname+".in").c_str());
		Fout((pname+".out").c_str());
	#else
		Fin("in.in");
	#endif
}
il void FILEIO_OICONTEST( string pname ){
	Fin((pname+".in").c_str());
	#ifndef intLSY
		Fout((pname+".out").c_str());
	#endif
}
void Printtime(){
	#ifdef intLSY
		double _timeuse = clock()* 1000.0 / CLOCKS_PER_SEC;
		fprintf(stderr,"\n\nTime usage:\n%.0lf ms\n",_timeuse);
	#endif
}
void END(){ Printtime(); exit(0); }
_tp<_tyn T>void END( T mes ){ cout << mes << endl; END(); }

// Debug
#define B cerr << "BreakPoint" << endl;
#define O(x) cerr << #x << " " << x << endl;
#define O_(x) cerr << #x << " " << x << "  ";
#define ERR(x) cerr << "ERR! #" << x << endl;
#define Msz(x) cerr << "Sizeof " << #x << " " << sizeof(x)/1024/1024 << " MB" << endl;
_tp<_tyn T>void Print( T a[] , int s , int t , char sp = ' ' , char ed = '\n' ){
	if( s > t ) return;
	for( int i = s ; i < t ; i++ )
		cout << a[i] << sp;
	cout << a[t] << ed;
	cout.flush();
}
_tp<_tyn T>void Print( T a , int s = 0 , int t = -1 , char sp = ' ' , char ed = '\n' ){
	if( t == -1 ) t = a.size()-1;
	for( int i = s ; i <= t ; i++ )
		cout << a[i] << sp;
	cout << ed;
	cout.flush();
}

// Optimize
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define Mymax(a,b) (a) = max((a),(b))
#define Mymin(a,b) (a) = min((a),(b))
#define INF (0x3f3f3f3f)
#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))
#define Sqr(x) ((x)*(x))
#define Lowbit(a) ((a)&(-(a)))
vc<int> Range( int l , int r ){
	vc<int> ret{};
	Forx(i,l,r) ret.Pb(i);
	return ret;
}
#define MOD (1000000007LL)
#define Rmoi(a,b) ((a)%b+b)%b
#define Rmo(a) ((a)%MOD+MOD)%MOD
#define Rmod(a) a = (a%MOD+MOD)%MOD
#define Rmodi(a,b) a = (a%(b)+(b))%(b)
#define Mymoi(a,b) ((a)>=b?((a)-b):(a))
#define Mymo(a) ((a)>=MOD?((a)-MOD):(a))
#define Mymod(a) a = (a)>=MOD?((a)-MOD):(a)
#define Mymodi(a,b) a = ((a)>=(b))?((a)-(b)):(a)
il ll Pow( ll a , ll b , const ll p = MOD ){
	ll ret = 1;
	for( ; b ; a = a*a%p, b >>= 1LL )
		if(b&1LL) ret = ret*a%p;
	return ret;
}
il ll Inv( ll a , const ll p = MOD ){ return Pow(a,p-2LL,p); }
const ll inv2 = Inv(2), inv3 = Inv(3), inv4 = Inv(4), inv5 = Inv(5);
const ll inv6 = Inv(6), inv7 = Inv(7), inv8 = Inv(8), inv9 = Inv(9), inv10 = Inv(10);
#define Bit(mask,pos) ((mask)<<1>>(pos)&1)
#define Add(mask,pos) ((mask)|1<<(pos)>>1)
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
#define MAXQ 64

ll n,q;
ll l[MAXQ], r[MAXQ];

ll PreCalc(){
	static vc<ll> as;
	For(i,q){ as.Eb(l[i]-1); as.Eb(r[i]); }
	sort(All(as));
	ll ans = Pow(10,as.front()) * Pow(10,n-as.back()) % MOD;
	For0(i,as.size()-1){
		if( as[i+1] == as[i] ) continue;
		ll tans = (Pow(10,as[i+1]-as[i])-1+MOD) * inv9 % MOD;
		ans = ans*tans % MOD;
	}
	return ans;
}

int dsu[MAXQ];
void DsuInit(){ For(i,MAXQ-1) dsu[i] = i; }
int Findfa( int pos ){ return dsu[pos] == pos ? pos : dsu[pos] = Findfa(dsu[pos]); }
void Unite( int a , int b ){
	a = Findfa(a);
	b = Findfa(b);
	if( a == b ) return;
	dsu[a] = b;
}

ll gx[MAXQ][MAXQ];
int cpcnt = 0;
void DP_Pre(){
	static vc<ll> as{};
	For(i,q){ as.Eb(l[i]-1); as.Eb(r[i]); }
	sort(All(as));
	as.resize( unique(All(as)) - as.begin() );

	static ll lrnk[MAXQ], rrnk[MAXQ];
	For(i,q){
		lrnk[i] = lower_bound(All(as),l[i]-1) - as.begin() + 1;
		rrnk[i] = lower_bound(All(as),r[i]) - as.begin() + 1;
	}
	// Print(lrnk,1,q);
	// Print(rrnk,1,q);

	static int cpid[MAXQ];
	For(i,MAXQ-1) For(j,MAXQ-1) gx[i][j] = 1;
	For(i,q) Unite(lrnk[i],rrnk[i]);
	int tot = as.size();
	For(i,tot){
		if( Findfa(i) != i ) continue;
		cpid[i] = ++cpcnt;
	}
	For(i,tot) cpid[i] = cpid[Findfa(i)];
	// Print(cpid,1,tot);

	For(i,tot-1){
		int id1 = cpid[i], id2 = cpid[i+1];
		ll p1 = as[i-1], p2 = as[i];
		ll t = (Pow(10,p2-p1)-1+MOD)*inv9 % MOD;
		ll mul = (t+1) * Inv(t) % MOD;
		if( id1 > id2 ) swap(id1,id2);
		( gx[id1][id2] *= mul ) %= MOD;
	}

	// For(i,q)
		// Print(gx[i],1,q);
}

#define MAXMASK 32768
ll subset_gx[MAXMASK];
void Pre_Subset_Gx(){
	int full = 1 << cpcnt;
	For0(msk,full){
		ll tans = 1;
		For(i,cpcnt)
			Forx(j,i,cpcnt)
				if( Bit(msk,i) and Bit(msk,j) )
					( tans *= gx[i][j] ) %= MOD;
		subset_gx[msk] = tans;
	}
}

ll mem[8][MAXMASK];
#define NOW mem[pos][inhand]
#define KNOW ~NOW
ll Dp( int pos , int inhand ){
	if(!inhand) return 1;
	if( pos == 8 ){ return subset_gx[inhand]; }
	if(KNOW) return NOW;
	ll ans = 0;
	for( int away = inhand ; ; away = (away-1)&inhand ){
		ll tans = subset_gx[away] * Dp(pos+1,inhand^away) % MOD;
		ans += tans; Mymod(ans);
		if(!away) break;
	}
	return NOW = ans;
}

/*
ll ans = 0;
int sel[MAXQ];
void Calc(){
	ll tans = 1;
	For(i,cpcnt)
		Forx(j,i,cpcnt)
			if( sel[i] == sel[j] )
				( tans *= gx[i][j] ) %= MOD;
	ans += tans;
	Mymod(ans);
}
void Dfs( int pos ){
	if( pos == cpcnt+1 ){
		Calc();
		return;
	}
	For0(i,9){
		sel[pos] = i;
		Dfs(pos+1);
	}
}
*/

int main(){
	FILEIO();
	Msn(mem,-1);

	Read(n,q);
	For(i,q) Read(l[i],r[i]);

	ll b = PreCalc();

	DsuInit();
	DP_Pre();
	Pre_Subset_Gx();

	ll ans = Dp(0,(1<<cpcnt)-1);
	ans = ans*b % MOD;
	ans = ans*inv9 % MOD;
	printf("%lld\n",ans);

	/*
	Dfs(1);
	O(ans);
	ans = ans*b % MOD;
	O(ans);
	O(ans*inv9 % MOD);
	*/

	END();
}


Measured memory_bytes: 2688