#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7;
const int max_m = 100110;
vector<int> vec;
pair<int, int> p[max_m];
long long sum[max_m];
long long dp[max_m];
bool cmp(pair<int, int> x, pair<int, int> y) {
  if (y.second != x.second) return x.second < y.second;
  return x.first < y.first;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> p[i].first >> p[i].second;
    vec.push_back(p[i].second);
  }
  sort(vec.begin(), vec.end());
  sort(p, p + m, cmp);
  long long ans = 0;
  int last = -1;
  for (int i = 0; i < m; i++) {
    if (p[i].first == 0) dp[i] = 1;
    if (i == 0) {
      sum[i] = dp[i];
      if (p[i].second == n) ans = (ans + dp[i]) % MOD;
      continue;
    }
    if (p[i].second != p[i - 1].second) last = i - 1;
    if (lower_bound(vec.begin(), vec.end(), p[i].first) - vec.begin() == 0) {
      if (last != -1) dp[i] = (dp[i] + sum[last]) % MOD;
    } else
      dp[i] += (sum[last] -
                sum[lower_bound(vec.begin(), vec.end(), p[i].first) -
                    vec.begin() - 1] +
                MOD) %
               MOD;
    sum[i] = (sum[i - 1] + dp[i]) % MOD;
    if (p[i].second == n) ans = (ans + dp[i]) % MOD;
  }
  cout << ans << endl;
  return 0;
}
