#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long n, m;
long long q[201010];
unordered_map<long long, long long> vis;
struct node {
  long long l, r;
  friend bool operator<(node s1, node s2) {
    if (s1.r == s2.r) return s1.l < s2.l;
    return s1.r < s2.r;
  }
} a[101100];
long long tr[201000];
long long lowbit(long long x) { return x & (-x); }
void add(long long pos, long long x) {
  while (pos <= vis[n]) tr[pos] = (tr[pos] + x) % mod, pos += lowbit(pos);
}
long long getsum(long long x) {
  long long ans = 0;
  while (x > 0) ans = (ans + tr[x]) % mod, x -= lowbit(x);
  return ans;
}
int main() {
  scanf("%lld%lld", &n, &m);
  long long num = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%lld%lld", &a[i].l, &a[i].r);
    q[++num] = a[i].l;
    q[++num] = a[i].r;
  }
  q[++num] = n;
  q[++num] = 0;
  sort(q + 1, q + 1 + num);
  num = unique(q + 1, q + 1 + num) - q - 1;
  for (int i = 1; i <= num; i++) vis[q[i]] = i;
  sort(a + 1, a + 1 + m);
  add(1, 1);
  for (int i = 1; i <= m; i++) {
    add(vis[a[i].r],
        (getsum(vis[a[i].r] - 1) % mod - getsum(vis[a[i].l] - 1) % mod + mod) %
            mod);
  }
  cout << ((getsum(vis[n]) - getsum(vis[n] - 1)) % mod + mod) % mod << endl;
}
