#include <bits/stdc++.h>
using namespace std;
int n, m;
const int N = 200005;
const long long MOD = 1e9 + 7;
set<int> loc;
map<int, int> compress;
long long dp[N];
long long dp_sum[N];
int q, r = 0;
vector<pair<int, int> > go;
int a[N], b[N];
long long rp(int i) {
  if (i < 0) return 0;
  return dp_sum[i];
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  loc.insert(0);
  loc.insert(n);
  for (int i = 0; i < m; ++i) {
    pair<int, int> p;
    cin >> p.second >> p.first;
    go.push_back(p);
    loc.insert(p.first);
    loc.insert(p.second);
  }
  for (set<int>::iterator i = loc.begin(); i != loc.end(); ++i) {
    compress[*i] = q++;
  }
  for (int i = 0; i < m; ++i) {
    go[i].first = compress[go[i].first];
    go[i].second = compress[go[i].second];
  }
  sort(go.begin(), go.end());
  dp[0] = 1;
  dp_sum[0] = 1;
  for (int i = 1; i < q; ++i) {
    long long &A = dp[i];
    A = 0;
    while (r < m && go[r].first == i) {
      A = (A + rp(i - 1) - rp(go[r].second - 1) + MOD) % MOD;
      ++r;
    }
    dp_sum[i] = (rp(i - 1) + A) % MOD;
  }
  cout << dp[q - 1] << "\n";
  return 0;
}
