#include <bits/stdc++.h>
using namespace std;
const int maxn = 202020, MOD = 1000000007;
int c[maxn];
void add(int p, int dt) {
  while (p < maxn) {
    c[p] = (c[p] + dt) % MOD;
    p += p & (-p);
  }
}
int ask(int p) {
  int ret = 0;
  while (p > 0) {
    ret = (ret + c[p]) % MOD;
    p -= p & (-p);
  }
  return ret;
}
int count(int l, int r) {
  int ret = (ask(r) - ask(l - 1)) % MOD;
  return (ret + MOD) % MOD;
}
int s[maxn], t[maxn], n, m, L, ord[maxn];
bool cmp(int a, int b) { return t[a] < t[b]; }
vector<int> vv;
int main() {
  scanf("%d%d", &L, &n);
  vv.push_back(0);
  vv.push_back(L);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &s[i], &t[i]);
    vv.push_back(s[i]);
    vv.push_back(t[i]);
  }
  sort(vv.begin(), vv.end());
  vv.erase(unique(vv.begin(), vv.end()), vv.end());
  for (int i = 1; i <= n; ++i) {
    s[i] = lower_bound(vv.begin(), vv.end(), s[i]) - vv.begin() + 1;
    t[i] = lower_bound(vv.begin(), vv.end(), t[i]) - vv.begin() + 1;
  }
  for (int i = 1; i <= n; ++i) ord[i] = i;
  sort(ord + 1, ord + 1 + n, cmp);
  int m = vv.size();
  add(1, 1);
  for (int i = 1; i <= n; ++i) {
    int p = ord[i];
    int num = count(s[p], t[p] - 1);
    add(t[p], num);
  }
  printf("%d\n", count(m, m));
  return 0;
}
