#include <bits/stdc++.h>
using namespace std;
long long n, m, ans = 0, f[100005] = {0}, sum[100005] = {0};
vector<pair<long long, long long> > a;
vector<long long> b;
signed main() {
  scanf("%lld%lld", &n, &m);
  for (register long long i = 0, x, y; i < m; i++)
    scanf("%lld%lld", &x, &y), a.push_back(make_pair(y, x)), b.push_back(y);
  sort(a.begin(), a.end()), sort(b.begin(), b.end());
  for (register long long i = 0, s, t; i < m; i++) {
    if (!a[i].second) f[i] = 1;
    s = lower_bound(b.begin(), b.end(), a[i].second) - b.begin(),
    t = lower_bound(b.begin(), b.end(), a[i].first) - b.begin();
    f[i] = (f[i] + sum[t] - sum[s] + 1000000007) % 1000000007,
    sum[i + 1] = (sum[i] + f[i]) % 1000000007;
  }
  for (register long long i = 0; i < m; i++)
    if (a[i].first == n) ans = (ans + f[i]) % 1000000007;
  printf("%lld", ans);
  return 0;
}
