#include <bits/stdc++.h>
using namespace std;
const int N = 100010, mod = 1e9 + 7;
int n, m;
pair<int, int> a[N], b[N];
long long dp[N], s;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    a[i] = {y, i};
    b[i] = {x, i};
  }
  sort(a + 1, a + m + 1);
  sort(b + 1, b + m + 1);
  for (int i = m, j = m; i >= 0; i--) {
    while (j && b[j].first > a[i].first) s = (s - dp[b[j].second]) % mod, j--;
    if (a[i].first == n)
      dp[a[i].second] = 1;
    else
      dp[a[i].second] = s;
    if (i && a[i - 1].first != a[i].first)
      for (int k = i; k <= m && a[k].first == a[i].first; k++)
        s = (s + dp[a[k].second]) % mod;
  }
  if (dp[0] < 0) dp[0] += mod;
  printf("%lld", dp[0]);
  return 0;
}
