#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > v;
unordered_map<long long, long long> fen;
long long n, m, s, t;
const long long mod = 1e9 + 7, N = 1e9 + 2;
struct BIT {
  inline BIT() { fen.max_load_factor(0.13); }
  void add(long long ind, long long d) {
    for (ind++; ind < N; ind += ind & (-ind)) fen[ind] = (fen[ind] + d) % mod;
  }
  long long get(long long ind) {
    long long sm = 0;
    for (ind++; ind; ind -= ind & (-ind)) sm = (sm + fen[ind]) % mod;
    return (sm);
  }
  long long get(long long l, long long r) {
    return ((get(r) - get(l - 1) + mod + mod) % mod);
  }
};
BIT f;
int32_t main() {
  scanf("%I64d %I64d", &n, &m);
  for (long long i = 0; i < m; i++) {
    scanf("%I64d %I64d", &s, &t);
    v.push_back({t, s});
  }
  sort(v.begin(), v.end());
  f.add(0, 1);
  for (auto x : v) f.add(x.first, f.get(x.second, x.first - 1));
  printf("%I64d", f.get(n, n) % mod);
}
