#include <bits/stdc++.h>
using namespace std;
struct data {
  long long u, v;
} a[100010];
bool operator<(data a, data b) {
  if (a.v == b.v) return a.u < b.u;
  return a.v < b.v;
}
long long get(long long u);
void update(long long u, long long gt);
long long n, m, mod, f[100010], g[200010], t[200010], dem, res;
set<long long> s;
set<long long>::iterator it;
map<long long, long long> ma;
int main() {
  ios::sync_with_stdio(0);
  scanf("%I64d %I64d", &n, &m);
  for (int i = (1), _b = (m); i <= _b; i++) {
    scanf("%I64d %I64d", &a[i].u, &a[i].v);
    s.insert(a[i].u);
    s.insert(a[i].v);
  }
  for (it = s.begin(); it != s.end(); it++) ma[*it] = ++dem;
  for (int i = (1), _b = (m); i <= _b; i++) {
    a[i].u = ma[a[i].u];
    a[i].v = ma[a[i].v];
  }
  n = ma[n];
  if (n == 0 || ma[0] == 0) {
    cout << 0;
    return 0;
  }
  mod = 1000000007;
  sort(a + 1, a + m + 1);
  for (int i = (1), _b = (m); i <= _b; i++)
    if (a[i].u == 1) f[i] = 1;
  int start = 1;
  int stop = 1;
  for (int i = (1), _b = (m); i <= _b; i++) {
    f[i] = (f[i] + get(a[i].u)) % mod;
    if (a[i].v != a[i + 1].v) {
      for (int j = (start), _b = (stop); j <= _b; j++) update(a[j].v, f[j]);
      start = i + 1;
      stop = i + 1;
    } else
      stop++;
  }
  for (int i = (1), _b = (m); i <= _b; i++)
    if (a[i].v == n) res = (res + f[i]) % mod;
  cout << res;
  return 0;
}
long long get(long long u) {
  long long sum = 0;
  while (u <= 200000) {
    sum = (sum + t[u]) % mod;
    u = u + (u & (-u));
  }
  return sum;
}
void update(long long u, long long gt) {
  while (u) {
    t[u] = (t[u] + gt) % mod;
    u = u - (u & (-u));
  }
}
