#include <bits/stdc++.h>
using namespace std;
int const INF = (1 << 30);
int const MAXN = (int)1e5 + 100;
int const mod = 1e9 + 7;
long long int d[2 * MAXN], c[300004], size, second[MAXN], t[MAXN];
vector<long long int> e[MAXN * 2];
long long int n, m, sum[MAXN * 2];
int main() {
  cin >> n >> m;
  c[size++] = 0;
  c[size++] = n;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    second[i] = x;
    t[i] = y;
    c[size++] = x;
    c[size++] = y;
  }
  sort(c, c + size);
  size = unique(c, c + size) - c;
  for (int i = 1; i <= m; i++) {
    int a = lower_bound(c, c + size, second[i]) - c;
    int b = lower_bound(c, c + size, t[i]) - c;
    e[b].push_back(a);
  }
  d[0] = 1;
  sum[1] = 1;
  for (int i = 1; i < size; i++) {
    for (int j = 0; j < e[i].size(); j++) {
      d[i] = (d[i] + sum[i] - sum[e[i][j]] + mod) % mod;
    }
    sum[i + 1] = (sum[i] + d[i]) % mod;
  }
  cout << d[size - 1];
  return 0;
}
