#include <bits/stdc++.h>
using namespace std;
int n, m;
pair<int, int> a[150000];
map<long long, long long> t;
vector<int> v;
map<int, vector<int> > g;
void add(long long x, long long v) {
  for (; x <= 1000000100; x |= (x + 1)) t[x] += v;
}
long long get(long long x) {
  long long r = 0;
  for (; x >= 0; x = (x & (x + 1)) - 1) r += t[x], r %= 1000000007;
  return r;
}
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.second < b.second) return 1;
  if (a.second == b.second && a.first < b.first) return 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    g[y].push_back(x);
    v.push_back(x);
    v.push_back(y);
  }
  sort(v.begin(), v.end());
  long long mod = 1000000007;
  add(0, 1);
  for (int i = 0; i < v.size(); ++i) {
    if (i && v[i] == v[i - 1]) continue;
    for (int j = 0; j < g[v[i]].size(); ++j) {
      int u = g[v[i]][j];
      long long x = get(v[i] - 1) - get(u - 1);
      x %= mod;
      x += mod;
      x %= mod;
      add(v[i], x);
    }
  }
  cout << ((get(n) - get(n - 1)) % mod + mod) % mod << endl;
}
