#include <bits/stdc++.h>
using namespace std;
pair<int, int> pl[200002 / 2];
long long sum[200002], dp[200002];
map<int, int> mp;
bool comp(const pair<int, int> &a, const pair<int, int> &b) {
  return a.second < b.second;
}
int main() {
  int n, m;
  cin >> n >> m;
  mp[0] = 0;
  mp[n] = 0;
  for (int i = 0; i < m; ++i) {
    cin >> pl[i].first >> pl[i].second;
    mp[pl[i].first] = 0;
    mp[pl[i].second] = 0;
  }
  int cc = 0;
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); ++it)
    it->second = cc++;
  for (int i = 0; i < m; ++i) {
    pl[i].first = mp[pl[i].first];
    pl[i].second = mp[pl[i].second];
  }
  sort(pl, pl + m, comp);
  int j = 0;
  dp[0] = 1;
  sum[0] = 0;
  for (int i = 0; i < cc; ++i) {
    while (j < m && pl[j].second == i) {
      dp[i] += sum[pl[j].second] - sum[pl[j].first];
      dp[i] %= 1000000007;
      ++j;
    }
    sum[i + 1] = (sum[i] + dp[i]) % 1000000007;
  }
  cout << ((int)((dp[cc - 1] % 1000000007 + 1000000007)) % 1000000007) << endl;
  return 0;
}
