#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
long long int n, m, ctr = 0;
long long int s[N], t[N], dp[N];
map<long long int, long long int> comp;
vector<long long int> g[N];
void hehe() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> s[i] >> t[i];
    comp[s[i]];
    comp[t[i]];
  }
  comp[0];
  comp[n];
  for (auto &it : comp) it.second = ++ctr;
  for (int i = 1; i <= m; i++) {
    s[i] = comp[s[i]], t[i] = comp[t[i]];
    g[t[i]].push_back(s[i]);
  }
  dp[1] = 1;
  for (int i = 2; i <= ctr; i++) {
    long long int ans = 0;
    for (auto &it : g[i]) ans += (dp[i - 1] - dp[it - 1]);
    ans %= MOD;
    ans += MOD;
    ans %= MOD;
    dp[i] = dp[i - 1] + ans;
    dp[i] %= MOD;
  }
  long long int ans = dp[ctr] - dp[ctr - 1] + MOD;
  ans %= MOD;
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    hehe();
  }
  return 0;
}
