#include <bits/stdc++.h>
using namespace std;
const int maxN = 100000 + 10;
const int MOD = 1000000007;
struct node {
  int s, t;
  inline void in() { scanf("%d %d", &s, &t); }
  inline bool operator<(const node &tmp) const {
    if (t != tmp.t) return t < tmp.t;
    return s < tmp.s;
  }
};
static int N, M;
static node A[maxN];
static int nQ;
static int Q[maxN * 2];
static map<int, int> g;
static int sum[maxN * 2];
static int dp[maxN * 2];
int main() {
  scanf("%d %d", &N, &M);
  nQ = 0;
  for (int i = 0; i < M; ++i) A[i].in(), Q[nQ++] = A[i].s, Q[nQ++] = A[i].t;
  sort(Q, Q + nQ);
  nQ = unique(Q, Q + nQ) - Q;
  g.clear();
  g[0] = 0;
  static int nT;
  nT = 1;
  for (int i = 0; i < nQ; ++i)
    if (Q[i] == 0 || Q[i] == N)
      continue;
    else
      g[Q[i]] = nT++;
  g[N] = nT;
  for (int i = 0; i < M; ++i) A[i].s = g[A[i].s], A[i].t = g[A[i].t];
  N = nT;
  for (int i = 1; i <= N + 1; ++i) dp[i] = sum[i] = 0;
  sort(A, A + M);
  dp[0] = 1;
  static int step;
  step = 0;
  for (int i = 0; i <= N; ++i) {
    while ((step < M) && A[step].t == i) {
      dp[i] = ((sum[i] - sum[A[step].s]) % MOD + dp[i]) % MOD;
      if (dp[i] < 0) dp[i] += MOD;
      ++step;
    }
    sum[i + 1] = (sum[i] + dp[i]) % MOD;
  }
  printf("%d\n", dp[N]);
  return 0;
}
