#include <bits/stdc++.h>
using namespace std;
const int _M = 100010;
const int MOD = 1000000007;
int n, m, f[_M], s[_M];
pair<int, int> a[_M];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < m; i++) cin >> a[i].second >> a[i].first;
  a[m++] = pair<int, int>(0, 0);
  sort(a, a + m);
  f[0] = s[0] = 1;
  for (int i = 1; i < m; i++) {
    int low = 0, high = i;
    while (high - low > 1) {
      int mid = (low + high) / 2;
      if (a[mid].first < a[i].first)
        low = mid;
      else
        high = mid;
    }
    if (low < high) {
      if (a[high].first < a[i].first)
        low = high;
      else
        high = low;
    }
    int upr = low + 1;
    low = 0, high = upr;
    while (high - low > 1) {
      int mid = (low + high) / 2;
      if (a[mid].first >= a[i].second)
        high = mid;
      else
        low = mid;
    }
    if (low < high) {
      if (a[low].first >= a[i].second)
        high = low;
      else
        low = high;
    }
    f[i] = (s[upr - 1] - ((high == 0) ? 0 : s[high - 1]) + MOD) % MOD;
    s[i] = (s[i - 1] + f[i]) % MOD;
  }
  int ans = 0;
  for (int i = 0; i < m; i++)
    if (a[i].first == n) ans = (ans + f[i]) % MOD;
  cout << ans << endl;
  return 0;
}
