#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
struct TE {
  int l, r;
} E[200100];
int n, tot, b[900100], m, tr[200100];
int low(int a) { return (a & (-a)); }
bool cmp(TE a, TE b) { return a.r < b.r; }
void ins(int a, long long b) {
  while (a <= tot) {
    tr[a] = ((long long)tr[a] + b) % mod;
    a += low(a);
  }
}
long long sum(int a) {
  long long ret = 0;
  while (a) {
    ret = (ret + (long long)tr[a]) % mod;
    a -= low(a);
  }
  return ret;
}
int main() {
  scanf("%d%d", &m, &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &E[i].l, &E[i].r);
    b[tot++] = E[i].l;
    b[tot++] = E[i].r;
  }
  b[tot++] = 0, b[tot++] = m;
  sort(b, b + tot);
  tot = unique(b, b + tot) - b;
  for (int i = 0; i < n; i++) {
    E[i].l = (lower_bound(b, b + tot, E[i].l) - b) + 1;
    E[i].r = (lower_bound(b, b + tot, E[i].r) - b) + 1;
  }
  ins(1, 1);
  sort(E, E + n, cmp);
  for (int i = 0; i < n; i++) {
    long long s = (sum(E[i].r - 1) - sum(E[i].l - 1) + mod) % mod;
    ins(E[i].r, s);
  }
  printf("%d\n", (sum(tot) - sum(tot - 1) + mod) % mod);
}
