#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9;
const int MOD = 1e9 + 7;
const int maxm = 1e5;
vector<pair<int, int> > ranks, ranke;
int ways[maxm];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> home;
  for (int i = 0; i < m; i++) {
    int s, t;
    cin >> s >> t;
    if (s == 0) home.push_back(i);
    ranks.push_back(pair<int, int>(s, i));
    ranke.push_back(pair<int, int>(t, i));
  }
  sort((ranks).begin(), (ranks).end());
  sort((ranke).begin(), (ranke).end());
  int sum = 0;
  for (int i = m - 1, j = m - 1, c = 0; i >= 0 && j >= 0;) {
    if (ranks[j].first > ranke[i].first && ranks[j].first != 0) {
      sum -= ways[ranks[j].second];
      if (sum < 0) sum += MOD;
      j--;
    } else {
      int sumsx = 0;
      int t = ranke[i].first;
      while (i >= 0 && ranke[i].first == t) {
        if (ranke[i].first == n) {
          ways[ranke[i].second] = 1;
          sumsx += 1;
          sumsx %= MOD;
        } else {
          ways[ranke[i].second] = sum;
          sumsx = (sumsx + sum) % MOD;
        }
        i--;
      }
      sum = (sum + sumsx) % MOD;
    }
  }
  int ans = 0;
  for (int i = 0; i < home.size(); i++) ans = (ans + ways[home[i]]) % MOD;
  cout << ans << endl;
}
