#include <bits/stdc++.h>
using namespace std;
struct AAA {
  long long a, b;
};
long long mmm = 1000000007;
AAA x[100010];
long long me[200010];
long long ss[200010];
bool cmp(AAA q, AAA w) { return (q.b < w.b); }
long long n, m;
long long dd[200010];
int bbb(long long xx) {
  int s = 0;
  int t = m;
  while (s + 1 < t) {
    if (xx <= x[(s + t) / 2].b) {
      t = (s + t) / 2;
    } else {
      s = (s + t) / 2;
    }
  }
  return s;
}
int main() {
  cin >> n >> m;
  int nn = 0;
  x[0].a = 0;
  x[0].b = 0;
  for (long long i = 1; i <= m; i++) cin >> x[i].a >> x[i].b;
  sort(x, x + 1 + m, cmp);
  memset(dd, 0, sizeof(dd));
  memset(ss, 0, sizeof(ss));
  ss[0] = 0;
  for (int i = 1; i <= m; i++) {
    int aa = bbb(x[i].a);
    int bb = bbb(x[i].b);
    ss[i] = (((ss[bb] - ss[aa] + 1000000007) % 1000000007) + ss[i - 1]) %
            1000000007;
    if (x[i].a == 0) ss[i] = (ss[i] + 1) % 1000000007;
  }
  long long an = 0;
  for (int i = m; i >= 1 && x[i].b == n; i--)
    an = (an + (ss[i] - ss[i - 1] + 1000000007) % 1000000007) % 1000000007;
  cout << an << endl;
  return 0;
}
