#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, mod = 1e9 + 7;
struct ii {
  int l, r;
} a[100005];
vector<int> all;
struct bit {
  int arr[500005];
  int lowbit(int x) { return x & (-x); }
  void add(int x, int y) {
    int i;
    for (i = x; i <= all.size(); i += lowbit(i)) {
      (arr[i] += y) %= mod;
    }
  }
  int query(int x) {
    int i, s = 0;
    for (i = x; i; i -= lowbit(i)) (s += arr[i]) %= mod;
    return s;
  }
} c;
bool cmp(ii x, ii y) { return x.r < y.r; }
int main() {
  scanf("%d%d", &n, &m);
  all.push_back(0);
  all.push_back(n);
  for ((i) = 1; (i) <= (m); (i)++) {
    scanf("%d%d", &a[i].l, &a[i].r);
    all.push_back(a[i].l);
    all.push_back(a[i].r);
  }
  sort(all.begin(), all.end());
  all.resize(unique(all.begin(), all.end()) - all.begin());
  sort(a + 1, a + m + 1, cmp);
  c.add(1, 1);
  for ((i) = 1; (i) <= (m); (i)++) {
    a[i].l = upper_bound(all.begin(), all.end(), a[i].l) - all.begin();
    a[i].r = upper_bound(all.begin(), all.end(), a[i].r) - all.begin();
    c.add(a[i].r, (c.query(a[i].r - 1) - c.query(a[i].l - 1)) % mod);
  }
  cout << ((c.query(all.size()) - c.query(all.size() - 1)) % mod + mod) % mod
       << endl;
  return 0;
}
