#include <bits/stdc++.h>
using namespace std;
long long n, m, sz, to, mod = 1e9 + 7, tr[400005];
pair<long long, long long> b[100005];
map<long long, long long> ord;
void add(long long id, long long d) {
  while (id <= sz) {
    tr[id] += d;
    id += id & -id;
  }
}
long long qry(long long l, long long r) {
  long long res = 0;
  while (r) {
    res += tr[r];
    r -= r & -r;
  }
  --l;
  while (l) {
    res -= tr[l];
    l -= l & -l;
  }
  return res % mod;
}
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second < b.second) return 1;
  if (a.second > b.second) return 0;
  return a.first < b.first;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (long long i = 0; i < m; ++i) {
    long long l, r;
    cin >> l >> r;
    b[i] = {l, r};
    ord[l] = 0;
    ord[r] = 0;
  }
  ord[0] = 0;
  ord[n] = 0;
  for (__typeof(ord.begin()) i = ord.begin(); i != ord.end(); ++i) {
    ord[i->first] = sz++;
  }
  for (long long i = 0; i < m; ++i) {
    b[i] = {ord[b[i].first] + 1, ord[b[i].second] + 1};
  }
  to = ord[n] + 1;
  for (long long i = 0; i < m; ++i) {
    if (b[i].first == 1) {
      add(1, 1);
      break;
    }
  }
  sort(b, b + m, cmp);
  long long j = 0;
  for (long long i = 2; i <= to; ++i) {
    long long cur = 0;
    while (b[j].second == i) {
      cur += qry(b[j].first, b[j].second) % mod;
      cur %= mod;
      ++j;
    }
    add(i, cur);
  }
  cout << qry(to, to) % mod << endl;
}
