#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200100;
const int MOD = 1000000007;
struct P {
  int s, t;
} p[MAXN];
bool cmp(P a, P b) { return a.t > b.t; }
long long sum[MAXN], dp[MAXN];
int main() {
  int i, j, k, m, n;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(dp, 0, sizeof(dp));
    map<int, int> mp;
    mp[0];
    mp[n];
    for (i = 0; i < m; i++) {
      scanf("%d%d", &p[i].s, &p[i].t);
      mp[p[i].s];
      mp[p[i].t];
    }
    n = 0;
    for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
      it->second = n++;
    }
    for (i = 0; i < m; i++) {
      p[i].s = mp[p[i].s];
      p[i].t = mp[p[i].t];
    }
    sort(p, p + m, cmp);
    int pi = m - 1, u;
    sum[0] = 0;
    dp[0] = 1;
    for (i = 0; i < n; i++) {
      while (pi >= 0 && p[pi].t == i) {
        dp[i] += sum[i] - sum[p[pi].s];
        pi--;
      }
      sum[i + 1] = (sum[i] + dp[i]) % MOD;
    }
    printf("%d\n", (int)(dp[n - 1] % MOD + MOD) % MOD);
  }
}
