#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-10;
template <typename T, typename S>
vector<T>& operator<<(vector<T>& a, S b) {
  a.push_back(b);
  return a;
}
template <typename T>
void operator>>(vector<T>& a, int b) {
  while (b--)
    if (!a.empty()) a.pop_back();
}
bool isprime(int n) {
  if (n < 2) return false;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
long long b_pow(long long x, long long n) {
  return n ? n == 1 ? x : b_pow(x, n >> 1) * b_pow(x, (n >> 1) + (n & 1)) : 1;
}
string itos(int n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
int n, m;
int bit[200005];
vector<pair<int, int> > v;
void add(int i, int x) {
  i++;
  while (i <= n) bit[i] += x, bit[i] %= 1000000007, i += i & -i;
}
int get(int i) {
  i++;
  int ans = 0;
  while (i > 0) ans += bit[i], ans %= 1000000007, i -= i & -i;
  return ans;
}
int main() {
  vector<int> co;
  while (cin >> n >> m) {
    co.push_back(0);
    co.push_back(n);
    for (int i = 0; i < m; i++) {
      int a, b;
      cin >> a >> b;
      v.push_back(make_pair(b, a));
      co.push_back(a);
      co.push_back(b);
    }
    sort(co.begin(), co.end());
    co.erase(unique(co.begin(), co.end()), co.end());
    for (int i = 0; i < m; i++)
      v[i].first = lower_bound(co.begin(), co.end(), v[i].first) - co.begin();
    for (int i = 0; i < m; i++)
      v[i].second = lower_bound(co.begin(), co.end(), v[i].second) - co.begin();
    sort(v.begin(), v.end());
    n = co.size();
    add(0, 1);
    for (int i = 0; i < v.size(); i++) {
      int to = v[i].first, from = v[i].second;
      add(to, get(to - 1) - get(from - 1));
    }
    cout << ((long long)get(n - 1) - get(n - 2) + 1000000007) % 1000000007
         << endl;
  }
}
