#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, M = 1e9 + 7;
struct ways {
  int s, t;
} w[N];
int p[N], dp[N], h[N];
int n, m, a, b, ans;
bool cmp(ways x, ways y) {
  if (x.t != y.t) return x.t < y.t;
  return x.s < y.s;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) cin >> w[i].s >> w[i].t;
  for (int i = 1; i <= m; i++) p[i] = w[i].t;
  sort(p + 1, p + m + 1);
  sort(w + 1, w + m + 1, cmp);
  for (int i = 1; i <= m; i++) {
    if (w[i].s == 0) dp[i] = 1;
    a = lower_bound(p + 1, p + m + 1, w[i].s) - p;
    b = lower_bound(p + 1, p + m + 1, w[i].t) - p;
    dp[i] = (dp[i] + h[b] - h[a] + M) % M;
    h[i + 1] = (dp[i] + h[i]) % M;
  }
  for (int i = 1; i <= m; i++)
    if (w[i].t == n) ans = (ans + dp[i]) % M;
  cout << ans << endl;
  return 0;
}
