#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   const long long INF = 1LL << 62;   const long long MINF = -(1LL << 62);   template <typename T>   T getint() {     T val = 0;     char c;     bool neg = false;     while ((c = getchar()) && !(c >=  0  && c <=  9 )) {       neg |= c ==  - ;     }     do {       val = (val * 10) + c -  0 ;     } while ((c = getchar()) && (c >=  0  && c <=  9 ));     return val * (neg ? -1 : 1);   }   const long long mod = 1e9 + 7;   const long long MAXN = 300010;   struct fenwick {     long long arr[MAXN];     fenwick() { memset(arr, 0, sizeof arr); }     void incr(int x, int by) {       for (; x < MAXN; x += (x & (-x))) {         arr[x] = (arr[x] + by) % mod;       }     }     int sum(int x) {       long long sum = 0;       for (; x > 0; x -= (x & (-x))) {         sum = (sum + arr[x]) % mod;       }       return sum;     }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n >> m;     vector<long long> c;     vector<pair<long long, long long>> lst(m);     for (int i = 0; i < m; ++i) cin >> lst[i].first >> lst[i].second;     for (int i = 0; i < m; ++i) {       c.push_back(lst[i].first);       c.push_back(lst[i].second);     }     c.push_back(0);     c.push_back(n);     sort((c).begin(), (c).end());     c.resize(distance(c.begin(), unique((c).begin(), (c).end())));     for (int i = 0; i < m; ++i) {       lst[i].first =           lower_bound((c).begin(), (c).end(), lst[i].first) - c.begin();       lst[i].second =           lower_bound((c).begin(), (c).end(), lst[i].second) - c.begin();     }     int st = 0;     st = lower_bound((c).begin(), (c).end(), st) - c.begin();     n = lower_bound((c).begin(), (c).end(), n) - c.begin();     fenwick f;     sort((lst).begin(), (lst).end(),          [&](pair<long long, long long>& egyik, pair<long long, long long>& masik)              -> bool { return egyik.second < masik.second; });     f.incr(st + 1, 1);     for (auto i : lst) {       long long ways = f.sum(i.second) - f.sum(i.first);       f.incr(i.second + 1, ways);     }     cout << (f.sum(n + 1) - f.sum(n) + mod) % mod <<   n ;     return 0;   }   