#include <bits/stdc++.h>
using namespace std;
long long s[200007], t[200007], n, m, Cnt, Dp[200007];
map<long long, long long> Comp;
vector<long long> Stop[200007];
int32_t main() {
  cin >> n >> m;
  for (long long i = 1; i <= m; ++i) {
    cin >> s[i] >> t[i];
    Comp[s[i]];
    Comp[t[i]];
  }
  Comp[0];
  Comp[n];
  for (auto &it : Comp) {
    ++Cnt;
    it.second = Cnt;
  }
  for (long long i = 1; i <= m; ++i) {
    s[i] = Comp[s[i]];
    t[i] = Comp[t[i]];
    Stop[t[i]].push_back(s[i]);
  }
  Dp[1] = 1;
  for (long long i = 2; i <= Cnt; ++i) {
    for (auto &Start : Stop[i]) Dp[i] = Dp[i] + Dp[i - 1] - Dp[Start - 1];
    Dp[i] = (Dp[i] % 1000000007 + 1000000007) % 1000000007;
    if (i == Cnt) cout << Dp[i] << "\n";
    Dp[i] = (Dp[i - 1] + Dp[i]) % 1000000007;
  }
  return 0;
}
