#include <bits/stdc++.h>
using namespace std;
const int M = 100005;
const int mod = 1000000007;
int add[M << 3];
int w[M << 1];
struct Nod {
  int a, b;
  bool operator<(const Nod& cmp) const { return b > cmp.b; }
} p[M];
void Down(int rt) {
  add[rt << 1] += add[rt];
  if (add[rt << 1] > mod) add[rt << 1] -= mod;
  add[rt << 1 | 1] += add[rt];
  if (add[rt << 1 | 1] > mod) add[rt << 1 | 1] -= mod;
  add[rt] = 0;
}
void update(int L, int R, int k, int l, int r, int rt) {
  if (L <= l && r <= R) {
    add[rt] = add[rt] + k;
    if (add[rt] > mod) add[rt] -= mod;
    return;
  }
  Down(rt);
  int m = (l + r) >> 1;
  ;
  if (L <= m) update(L, R, k, l, m, rt << 1);
  if (m < R) update(L, R, k, m + 1, r, rt << 1 | 1);
}
int query(int d, int l, int r, int rt) {
  if (l == r) return add[rt];
  Down(rt);
  int m = (l + r) >> 1;
  ;
  if (d <= m)
    return query(d, l, m, rt << 1);
  else
    return query(d, m + 1, r, rt << 1 | 1);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int tt = 0;
  w[tt++] = 0;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &p[i].a, &p[i].b);
    w[tt++] = p[i].a;
    w[tt++] = p[i].b;
  }
  w[tt++] = n;
  sort(w, w + tt);
  sort(p, p + m);
  int u = unique(w, w + tt) - w;
  int d = lower_bound(w, w + u, n) - w;
  update(d, d, 1, 0, u - 1, 1);
  for (int i = 0; i < m; i++) {
    int ll = lower_bound(w, w + u, p[i].a) - w;
    int rr = lower_bound(w, w + u, p[i].b) - w;
    int cnt = query(rr, 0, u - 1, 1);
    update(ll, rr - 1, cnt, 0, u - 1, 1);
  }
  printf("%d\n", query(0, 0, u - 1, 1));
  return 0;
}
