#include <bits/stdc++.h>
using namespace std;
struct Counter {
  static int k;
  Counter() { k++; }
  ~Counter() { k--; }
};
int Counter::k = 0;
template <typename T>
void pr(const string& name, T t) {
  cout << name << " = " << t << endl;
}
template <typename T, typename... Types>
void pr(const string& names, T t, Types... rest) {
  auto comma_pos = names.find(',');
  cout << names.substr(0, comma_pos) << " = " << t << ", ";
  auto next_name_pos = names.find_first_not_of(" \t\n", comma_pos + 1);
  pr(string(names, next_name_pos), rest...);
}
void mod(long long& a, long long b) {
  a %= b;
  if (a < 0) a += b;
}
const long long MOD = 1000000007;
int B, N, Stops;
long long T[200005];
map<int, int> M;
pair<int, int> Bus[100005];
set<int> S;
long long query(int x) {
  long long ret = 0;
  while (x > 0) {
    ret += T[x];
    ret %= MOD;
    x -= x & -x;
  }
  return ret;
}
long long query(int a, int b) { return (query(b) - query(a - 1) + MOD) % MOD; }
void add(int x, long long v) {
  while (x <= Stops) {
    T[x] += v;
    T[x] %= MOD;
    x += x & -x;
  }
}
int main() {
  cin >> N >> B;
  S.insert(0), S.insert(N);
  for (int i = (1); i <= (B); i++) cin >> Bus[i].second >> Bus[i].first;
  for (int i = (1); i <= (B); i++)
    S.insert(Bus[i].first), S.insert(Bus[i].second);
  int c = 0;
  for (int k : S) M[k] = ++c;
  Stops = c;
  for (int i = (1); i <= (B); i++)
    Bus[i].first = M[Bus[i].first], Bus[i].second = M[Bus[i].second];
  sort(Bus + 1, Bus + B + 1);
  add(1, 1);
  for (int i = (1); i <= (B); i++) {
    pair<int, int> p = Bus[i];
    add(p.first, query(p.second, p.first - 1));
  }
  cout << query(Stops, Stops);
}
