#include <bits/stdc++.h>
using namespace std;
const int N = 200200, MOD = 1e9 + 7;
int n, m, s, t, i, sum, BIT[N];
pair<int, int> p[N];
map<int, int> mp;
inline void update(int idx, int val) {
  while (idx <= n) {
    BIT[idx] = (BIT[idx] + val) % MOD;
    idx += idx & -idx;
  }
}
inline int get(int idx) {
  int sum = 0;
  while (idx > 0) {
    sum = (sum + BIT[idx]) % MOD;
    idx -= idx & -idx;
  }
  return sum;
}
int main() {
  cin >> n >> m;
  for (i = 0; i < m; ++i) {
    scanf("%d %d", &p[i].second, &p[i].first);
    mp[p[i].first];
    mp[p[i].second];
  }
  sort(p, p + m);
  mp[0] = mp[n] = i = 0;
  for (auto& it : mp) {
    it.second = ++i;
  }
  n = mp[n];
  update(mp[0], 1);
  for (i = 0; i < m; ++i) {
    s = mp[p[i].second];
    t = mp[p[i].first];
    sum = ((get(t - 1) - get(s - 1)) % MOD + MOD) % MOD;
    update(t, sum);
  }
  sum = ((get(n) - get(n - 1)) % MOD + MOD) % MOD;
  cout << sum << endl;
  return 0;
}
