#include <bits/stdc++.h>
using namespace std;
const int MOD9 = 1e9 + 7;
const int MOD91 = 1e9 + 9;
const long long MOD12 = 1e12 + 39LL;
const long long MOD15 = 1e15 + 37LL;
const int INF = 1e9;
const int base = 1e9;
const int MAX = 2e5;
const long double EPS = 1e-10;
pair<int, int> a[200200];
map<int, int> foo;
long long sum[200200];
long long k[200200];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = (0); i < (m); ++i) {
    scanf("%d %d", &a[i].second, &a[i].first);
    foo[a[i].first] = 1;
    foo[a[i].second] = 1;
  }
  foo[0] = 1;
  foo[n] = 1;
  int iPos = 0;
  for (auto &iter : foo) {
    iter.second = iPos;
    iPos++;
  }
  for (int i = (0); i < (m); ++i) {
    a[i].first = foo[a[i].first];
    a[i].second = foo[a[i].second];
  }
  sort(a, a + m);
  int j = 0;
  sum[0] = 0;
  k[0] = 1;
  for (int i = (0); i < (iPos); ++i) {
    while (a[j].first == i) {
      k[i] += sum[a[j].first] - sum[a[j].second];
      k[i] += 1000000007;
      k[i] %= 1000000007;
      j++;
    }
    sum[i + 1] = sum[i] + k[i];
    sum[i + 1] %= 1000000007;
  }
  cout << k[iPos - 1];
  return 0;
}
