#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9, maxn = 2e5 + 723, N = 1e6 + 20, LOG = 21, mod = 1e9 + 7;
const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
const long double eps = 1e-12, pi = 3.14159265359;
const pair<unsigned long long, unsigned long long> base = make_pair(1171, 3307);
const long long INF = 1e18;
int n, m, k, l[maxn], r[maxn], a[maxn];
int dp[maxn], pr[maxn];
vector<pair<int, int> > v[maxn];
set<int> q;
int get(int l, int r) {
  if (l > r) return 0;
  return (pr[r] - (!l ? 0 : pr[l - 1]) + mod) % mod;
}
void add(int &x, int y) {
  x = (x + y) % mod;
  if (x < 0) x += mod;
}
int main() {
  cin >> n >> m;
  q.insert(0);
  q.insert(n);
  for (int i = 0; i < m; ++i) {
    cin >> l[i] >> r[i];
    q.insert(l[i]);
    q.insert(r[i]);
  }
  for (set<int>::iterator it = q.begin(); it != q.end(); ++it) a[k++] = *it;
  for (int i = 0; i < m; ++i) {
    int lf = (lower_bound(a, a + k, l[i]) - a),
        rg = (lower_bound(a, a + k, r[i]) - a);
    v[rg].push_back(make_pair(lf, rg));
  }
  dp[0] = 1;
  pr[0] = 1;
  for (int i = 1; i < k; ++i) {
    pr[i] = pr[i - 1];
    for (int j = 0; j < v[i].size(); ++j)
      add(dp[i], get(v[i][j].first, v[i][j].second - 1));
    add(pr[i], dp[i]);
  }
  cout << dp[k - 1] << '\n';
  return 0;
}
