#include <bits/stdc++.h>
using namespace std;
const long long N = 100000;
const long long inf = (long long)1e9;
const long long MOD = (long long)1e9 + 7;
const long double eps = 1e-6;
const long long ABC = 26;
const long long P = 239;
vector<long long> F;
void build(long long n) { F.resize(n, 0); }
void add(long long x, long long val) {
  for (; x < F.size(); x = x | (x + 1)) F[x] = (F[x] + val) % MOD;
}
long long get(long long x) {
  long long res = 0;
  for (; x >= 0; x = (x & (x + 1)) - 1) res = (res + F[x]) % MOD;
  return res;
}
long long get(long long l, long long r) {
  return (get(r) - get(l - 1) + MOD) % MOD;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long r, m;
  cin >> r >> m;
  set<long long> s;
  s.insert(0);
  s.insert(r);
  long long a[m][2];
  for (long long i = 0; i < m; i++) {
    cin >> a[i][0] >> a[i][1];
    s.insert(a[i][1]);
  }
  vector<long long> b;
  for (auto x : s) b.push_back(x);
  sort(b.begin(), b.end());
  long long n = b.size();
  map<long long, long long> mt;
  for (long long i = 0; i < n; i++) mt[b[i]] = i;
  vector<vector<long long> > bus(n);
  for (long long i = 0; i < m; i++) bus[mt[a[i][1]]].push_back(i);
  build(n);
  vector<long long> dp(n, 0);
  dp[0] = 1;
  add(0, dp[0]);
  for (long long i = 1; i < n; i++) {
    for (long long j : bus[i])
      dp[i] = (dp[i] + get(lower_bound(b.begin(), b.end(), a[j][0]) - b.begin(),
                           i - 1)) %
              MOD;
    add(i, dp[i]);
  }
  cout << dp[n - 1];
  return 0;
}
