#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 100005;
int n, m, ans, dp[N], sum[N];
pair<int, int> a[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) scanf("%d%d", &a[i].second, &a[i].first);
  sort(a + 1, a + m + 1);
  sum[0] = 1;
  for (int i = 1; i <= m;) {
    int j;
    for (j = i; j <= m && a[j].first == a[i].first; ++j) {
      int pos = lower_bound(a, a + i, pair<int, int>(a[j].second, 0)) - a;
      if (pos != -1)
        dp[i] = (sum[i - 1] - sum[pos - 1] + mod) % mod;
      else
        dp[i] = sum[i - 1];
      sum[j] = (sum[j - 1] + dp[i]) % mod;
      if (a[j].first == n) ans = (ans + dp[i]) % mod;
    }
    i = j;
  }
  printf("%d", ans);
  return 0;
}
