#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5, mod = 1e9 + 7;
int bit[maxn << 1];
int s[maxn], t[maxn], n, m;
vector<int> v;
vector<pair<int, int> > p;
void add(int i, int val) {
  while (i <= v.size()) {
    bit[i] += val;
    if (bit[i] >= mod) bit[i] -= mod;
    ;
    i += i & -i;
  }
}
int sum(int i) {
  int cnt = 0;
  while (i) {
    cnt += bit[i];
    if (cnt >= mod) cnt -= mod;
    i &= i - 1;
  }
  return cnt;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> t[i];
    v.push_back(s[i]);
    v.push_back(t[i]);
  }
  v.push_back(0);
  v.push_back(n);
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  for (int i = 0; i < m; i++) {
    s[i] = lower_bound(v.begin(), v.end(), s[i]) - v.begin() + 1;
    t[i] = lower_bound(v.begin(), v.end(), t[i]) - v.begin() + 1;
    p.push_back(pair<int, int>(t[i], s[i]));
  }
  sort(p.begin(), p.end());
  add(1, 1);
  for (int i = 0; i < p.size(); i++)
    add(p[i].first, (sum(p[i].first - 1) - sum(p[i].second - 1) + mod) % mod);
  cout << (sum(v.size()) - sum(v.size() - 1) + mod) % mod << endl;
  return 0;
}
