#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 10;
const long long MOD = 1e9 + 7;
pair<int, int> p[MAX];
int n, m, lis[MAX], tol;
long long c[MAX];
void update(int i, long long k) {
  while (i <= tol + 1) {
    c[i] += k;
    c[i] %= MOD;
    i += i & (-i);
    ;
  }
}
long long getsum(int i) {
  long long res = 0;
  while (i > 0) {
    res += c[i];
    res %= MOD;
    i -= i & (-i);
    ;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false), cout.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < m; i++) cin >> p[i].second >> p[i].first;
  sort(p, p + m);
  lis[++tol] = 0;
  for (int i = 0; i < m; i++) {
    if (i && p[i].first == p[i - 1].first) continue;
    lis[++tol] = p[i].first;
  }
  lis[++tol] = n;
  update(1, 1);
  for (int i = 0; i < m; i++) {
    int l = lower_bound(lis + 1, lis + tol + 1, p[i].second) - lis,
        r = lower_bound(lis + 1, lis + tol + 1, p[i].first) - lis;
    long long u = (getsum(r - 1) - getsum(l - 1) + MOD) % MOD;
    update(r, u);
  }
  int id = lower_bound(lis + 1, lis + tol + 1, n) - lis;
  cout << (getsum(id) - getsum(id - 1) + MOD) % MOD << endl;
  return 0;
}
