#include <bits/stdc++.h>
using namespace std;
long long dp[100010];
int start_map[100010];
int end_map[100010];
long long sum(int idx) {
  if (idx == 0) return 0;
  long long sum = 0;
  while (idx > 0) {
    sum += dp[idx];
    idx -= (idx & -idx);
  }
  return sum % 1000000007;
}
long long M(long v) {
  v %= 1000000007;
  if (v < 0) v += 1000000007;
  return v;
}
void add(int idx, long long to_add, int MAXVAL) {
  while (idx <= MAXVAL) {
    dp[idx] = (dp[idx] + to_add) % 1000000007;
    idx += (idx & -idx);
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<pair<int, int> > buses;
  vector<pair<int, int> > starts;
  vector<pair<int, int> > ends;
  memset(dp, 0, sizeof(dp));
  memset(start_map, 255, sizeof(start_map));
  memset(end_map, 255, sizeof(end_map));
  buses.push_back(make_pair(0, 0));
  buses.push_back(make_pair(0, 0));
  buses.push_back(make_pair(n + 1, n));
  for (int i = 0; i < m; i++) {
    int s, t;
    scanf("%d%d", &s, &t);
    buses.push_back(make_pair(t, s));
  }
  sort(buses.begin(), buses.end());
  for (int i = 0; i < buses.size(); i++) {
    starts.push_back(make_pair(buses[i].second, i));
    ends.push_back(make_pair(buses[i].first, i));
  }
  sort(starts.begin(), starts.end());
  sort(ends.begin(), ends.end());
  int j = 1;
  for (int i = 1; i < ends.size(); i++) {
    int cur_idx = ends[i].second;
    while (j < starts.size() && starts[j].first <= ends[i].first) {
      int set_idx = starts[j].second;
      if (starts[j].first <= ends[i].first &&
          buses[set_idx].first > ends[i].first)
        start_map[set_idx] = cur_idx - 1;
      j++;
    }
  }
  for (int i = 1; i < ends.size();) {
    int orig = ends[i].first;
    int orig_idx = ends[i].second;
    while (i < ends.size() && ends[i].first == orig) {
      end_map[ends[i].second] = orig_idx - 1;
      i++;
    }
  }
  add(1, 1, buses.size() - 1);
  for (int i = 2; i < buses.size(); i++) {
    int start = start_map[i];
    int end = end_map[i];
    if (start == -1 || end == -1) continue;
    add(i, M(sum(end) - sum(start)), buses.size() - 1);
  }
  printf("%lld\n", M(sum(buses.size() - 1) - sum(buses.size() - 2)));
  return 0;
}
