#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int sum[100005];
int dp[100005];
int n, m, ans;
pair<int, int> ar[100005];
int pos[100005];
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int s, t;
    cin >> s >> t;
    ar[i] = {t, s};
    pos[i] = t;
  }
  sort(ar, ar + m);
  sort(pos, pos + m);
  for (int i = 0; i < m; i++) {
    int u = ar[i].first, v = ar[i].second;
    if (!v) dp[i] = 1;
    int start = lower_bound(pos, pos + m, v) - pos;
    int end = lower_bound(pos, pos + m, u) - pos;
    dp[i] = (dp[i] + sum[end] - sum[start] + MOD) % MOD;
    sum[i + 1] = (sum[i] + dp[i]) % MOD;
  }
  for (int i = 0; i < m; i++) {
    if (pos[i] == n) {
      ans = (ans + dp[i]) % MOD;
    }
  }
  cout << ans << '\n';
  return 0;
}
