#include <bits/stdc++.h>
#pragma GCC optimize "03"
using namespace std;
const long long int N = 1e5 + 5;
const long long int mod = 1e9 + 7;
const long long int inf = 1e9 + 9;
map<long long int, long long int> a;
map<long long int, vector<long long int> > v;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, m;
  cin >> n >> m;
  for (long long int i = 1; i <= m; i++) {
    long long int s, t;
    cin >> s >> t;
    v[t].push_back(s);
    a[-t] = 0;
  }
  long long int cur = 0;
  for (auto i : a) {
    long long int x = -i.first;
    cur += i.second;
    i.second = cur;
    cur %= mod;
    if (x == n) i.second = 1;
    for (auto j : v[x]) {
      a[-(x - 1)] += i.second;
      a[-(x - 1)] %= mod;
      if (j != 0) a[-(j - 1)] += mod - i.second, a[-(j - 1)] %= mod;
    }
  }
  cout << cur;
  return 0;
}
