#include <bits/stdc++.h>
using namespace std;
int n, m, cnt, s[100005], t[100005], bit[200005];
map<int, int> pos;
vector<int> p;
vector<pair<int, int> > r;
int lowb(int x) { return x & (-x); }
void add(int x, int y) {
  while (x <= n) {
    bit[x] += y;
    bit[x] %= 1000000007;
    x += lowb(x);
  }
}
int sum(int x) {
  int s = 0;
  while (x >= 1) {
    s += bit[x];
    s %= 1000000007;
    x -= lowb(x);
  }
  return s;
}
int main() {
  cin >> n >> m;
  p.push_back(0);
  p.push_back(n);
  for (int i = 1; i <= m; i++) {
    cin >> s[i] >> t[i];
    p.push_back(s[i]);
    p.push_back(t[i]);
  }
  sort(p.begin(), p.end());
  p.erase(unique(p.begin(), p.end()), p.end());
  for (int i = 0; i < p.size(); i++) pos[p[i]] = ++cnt;
  n = pos[n];
  for (int i = 1; i <= m; i++) {
    s[i] = pos[s[i]];
    t[i] = pos[t[i]];
    r.push_back(make_pair(t[i], s[i]));
  }
  sort(r.begin(), r.end());
  add(1, 1);
  for (int i = 0; i < r.size(); i++)
    add(r[i].first, sum(r[i].first - 1) - sum(r[i].second - 1));
  cout << (sum(n) - sum(n - 1) + 1000000007) % 1000000007 << endl;
  return 0;
}
