#include <bits/stdc++.h>
using namespace std;
template <typename T>
T next_int() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') {
    p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * p;
}
const int max_n = (int)2e5 + 228;
const int max_int = (int)1e9 + 228;
const int MOD = (int)1e9 + 7;
map<int, int> b;
pair<int, int> a[max_n];
int dp[max_n];
vector<int> c[max_n];
vector<int> q;
int d[max_n];
void modi(int p, int dl) {
  for (int i = p; i < max_n; i += (i & (-i))) d[i] = (dl + d[i]) % MOD;
}
int get(int p) {
  int ans = 0;
  for (int i = p; i >= 1; i -= (i & (-i))) ans = (ans + d[i]) % MOD;
  return ans;
}
int sum(int l, int r) { return (get(r) - get(l - 1) + MOD) % MOD; }
int main() {
  int n = next_int<int>();
  int m = next_int<int>();
  for (int i = 0; i < m; i++) {
    a[i] = make_pair(next_int<int>(), next_int<int>());
    q.push_back(a[i].first);
    q.push_back(a[i].second);
  }
  q.push_back(0);
  q.push_back(n);
  sort(q.begin(), q.end());
  int k = 1;
  for (int i = 0; i < q.size(); i++) {
    if (i && q[i] != q[i - 1]) k++;
    b[q[i]] = k;
  }
  for (int i = 0; i < m; i++) {
    swap(a[i].first, a[i].second);
    a[i].first = b[a[i].first];
    a[i].second = b[a[i].second];
    c[a[i].second].push_back(a[i].first);
  }
  modi(1, 1);
  dp[1] = 1;
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < c[i].size(); j++) {
      int pr = dp[i];
      dp[i] = (dp[i] + sum(c[i][j], i - 1)) % MOD;
      modi(i, (dp[i] - pr + MOD) % MOD);
    }
  }
  cout << dp[k] << "\n";
}
