#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 77, Mod = 1e9 + 7;
int n, m;
pair<int, int> a[N];
unordered_map<int, int> fen;
void add(int x, int val) {
  for (; x < Mod; x += x & -x) {
    fen[x] = (fen[x] + val) % Mod;
  }
}
int get(int x) {
  int ret = 0;
  for (; x; x -= x & -x) {
    ret = (ret + fen[x]) % Mod;
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  n++;
  for (int i = 1; i <= m; i++) {
    cin >> a[i].second >> a[i].first;
    a[i].first++;
    a[i].second++;
  }
  sort(a + 1, a + 1 + m);
  add(1, 1);
  for (int i = 1; i <= m; i++) {
    int t = (get(a[i].first - 1) - get(a[i].second - 1)) % Mod;
    t = (t + Mod) % Mod;
    add(a[i].first, t);
  }
  int A = (get(n) - get(n - 1)) % Mod;
  if (A < 0) A += Mod;
  cout << A;
  return 0;
}
