#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 5, MOD = 1e9 + 7;
int M, N, dp[MAX], sum[MAX];
pair<int, int> A[MAX];
vector<int> v;
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  return a.second < b.second;
}
int main() {
  scanf("%d%d", &M, &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d%d", &A[i].first, &A[i].second);
    v.push_back(A[i].first);
    v.push_back(A[i].second);
  }
  v.push_back(0);
  v.push_back(M);
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  for (int i = 0; i < N; ++i) {
    A[i].first = lower_bound(v.begin(), v.end(), A[i].first) - v.begin();
    A[i].second = lower_bound(v.begin(), v.end(), A[i].second) - v.begin();
  }
  sort(A, A + N, cmp);
  dp[0] = 1;
  sum[0] = 1;
  int k = 0;
  for (int i = 1; i <= v.size() - 1; ++i) {
    sum[i] = sum[i - 1];
    while (k < N && A[k].second == i) {
      int l = A[k].first, r = A[k].second;
      int t = (sum[r - 1] - (l > 0 ? sum[l - 1] : 0) + MOD) % MOD;
      dp[i] = (dp[i] + t) % MOD;
      sum[i] = (sum[i] + t) % MOD;
      ++k;
    }
  }
  printf("%d\n", dp[v.size() - 1]);
  return 0;
}
