#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const int inf = (int)1e9;
const int MAX_N = 100 * 1000 + 10;
const int REM = inf + 7;
set<int> S;
map<int, int> cor;
vector<pair<int, int> > v;
int dp[2 * MAX_N], sum[2 * MAX_N];
int n, m;
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    v.push_back(pair<int, int>(y, x));
    if (x && x != n) S.insert(x);
    if (y && y != n) S.insert(y);
  }
  int c = 1;
  cor[0] = 0;
  set<int>::iterator it;
  for (it = S.begin(); it != S.end(); it++) {
    cor[*it] = c++;
  }
  cor[n] = c++;
  for (int i = 0; i < ((int)v.size()); i++) {
    v[i].first = cor[v[i].first];
    v[i].second = cor[v[i].second];
  }
  sort(v.begin(), v.end());
  sum[0] = dp[0] = 1;
  int idx = 0;
  for (int i = 1; i < c; i++) {
    for (; idx < ((int)v.size()) && v[idx].first == i; idx++) {
      int cur = sum[v[idx].first - 1];
      if (v[idx].second) {
        cur -= sum[v[idx].second - 1];
        while (cur < 0) cur += REM;
      }
      dp[i] += cur;
      dp[i] %= REM;
    }
    sum[i] = sum[i - 1] + dp[i];
    sum[i] %= REM;
  }
  cout << dp[c - 1] << endl;
  return 0;
}
