#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const double eps = 1e-8;
const int iinf = INT_MAX;
const long long linf = 2e18;
const double dinf = 1e30;
const int MOD = 1000000007;
inline int read() {
  int X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  return w ? -X : X;
}
void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
void print(int x) {
  cout << x << '\n';
  exit(0);
}
void PRINT(string x) {
  cout << x << '\n';
  exit(0);
}
void douout(double x) { printf("%lf\n", x + 0.0000000001); }
int dp[N], sum[N];
int n, m, ans;
int main() {
  scanf("%d%d", &n, &m);
  vector<pair<int, int> > a(m);
  vector<int> v(m);
  for (int i = 0, s, t; i < m; i++) {
    scanf("%d%d", &s, &t);
    a[i] = make_pair(t, s);
    v[i] = t;
  }
  sort(a.begin(), a.end());
  sort(v.begin(), v.end());
  for (int i = 0; i < m; i++) {
    int f = a[i].second, t = a[i].first;
    if (f == 0) dp[i] = 1;
    int S = lower_bound(v.begin(), v.end(), f) - v.begin();
    int T = lower_bound(v.begin(), v.end(), t) - v.begin();
    dp[i] = (dp[i] + sum[T] - sum[S] + MOD) % MOD;
    sum[i + 1] = (sum[i] + dp[i]) % MOD;
  }
  for (int i = 0; i < m; i++)
    if (a[i].first == n) ans = (ans + dp[i]) % MOD;
  printf("%d\n", ans);
}
