#include <bits/stdc++.h>
long long gcd(long long a, long long b) {
  while (a && b) {
    if (a > b)
      a %= b;
    else
      b %= a;
  }
  return a + b;
}
long long lcm(long long a, long long b) { return (((a) / gcd(a, b))) * b; }
int phi(int n) {
  int result = n;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      result -= result / i;
    }
  }
  if (n > 1) result -= result / n;
  return result;
}
long long power(long long a, long long b, long long c) {
  long long r = 1;
  while (b) {
    if (b & 1) r *= a;
    a *= a;
    a %= c;
    r %= c;
    b /= 2;
  }
  return r;
}
void nxi(int& n) {
  bool min = 0;
  char c;
  n = 0;
  while ((c = getc(stdin)) && c <= 32)
    ;
  if (c == '-')
    min = 1;
  else
    n = c - 48;
  while ((c = getc(stdin)) && c > 32) n = (n << 3) + (n << 1) + c - 48;
  if (min) n = -n;
}
void prl(int n) {
  if (n == 0) {
    puts("0");
    return;
  }
  static int s[10];
  int top = 0;
  while (n > 0) s[top++] = n % 10, n /= 10;
  while (top--) putchar(s[top] + 48);
}
using namespace std;
int n, m;
pair<int, int> mem[101010];
map<long long, vector<long long> > sv;
map<long long, long long> t;
void inc(int pos, long long val) {
  for (long long i = pos; i < 1000000007; i = (i | (i + 1))) {
    t[i] += val, t[i] %= 1000000007;
  }
}
long long get(int r) {
  long long s = 0;
  for (long long i = r; i >= 0; i = (i & (i + 1)) - 1) {
    if (t.count(i)) {
      s += t[i];
      s %= 1000000007;
    }
  }
  return s;
}
long long get(int l, int r) {
  long long x = (long long)get(r) - (l > 0 ? 1ll * get(l - 1) : 0);
  x = (x + 1000000007) % 1000000007;
  x = (x + 1000000007) % 1000000007;
  return x;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> mem[i].first >> mem[i].second;
    int x = mem[i].second;
    sv[x].push_back(mem[i].first);
  }
  inc(0, 1);
  for (map<long long, vector<long long> >::iterator it = sv.begin();
       it != sv.end(); it++) {
    long long s = 0;
    int x = it->first;
    for (int i = 0; i < it->second.size(); i++) {
      s += get(it->second[i], x - 1);
      s %= 1000000007;
      s = (s + 1000000007) % 1000000007;
      s = (s + 1000000007) % 1000000007;
    }
    inc(x, s);
  }
  cout << get(n, n) << endl;
  return 0;
}
