#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 4, MOD = 1e9 + 7;
long long ans;
int n, m, x, y, pre[N];
pair<int, int> p[N];
long long dp[N] = {1};
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d", &x, &y);
    p[i] = {y, x};
  }
  sort(p, p + m + 1);
  for (int i = 1; i <= m; ++i) {
    if (p[i].first > p[i - 1].first)
      pre[i] = i - 1;
    else
      pre[i] = pre[i - 1];
  }
  for (int i = 1; i <= m; i++) {
    int r = pre[i], l = lower_bound(p, p + i, make_pair(p[i].second, 0)) - p;
    dp[i] = (dp[r] - dp[l - 1]) % MOD;
    if (p[i].first == n) ans = (ans + dp[i] + MOD) % MOD;
    dp[i] = (dp[i] + dp[i - 1]) % MOD;
  }
  cout << ans;
  return 0;
}
