#include <bits/stdc++.h>
using namespace std;
struct seg {
  int a, b;
};
bool pabcomp(const seg& a, const seg& b) { return a.b < b.b; }
int main() {
  int i, n, m, budu[100001], sumbudu[100001], ats = 0;
  seg segs[100001], tmp;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d", &segs[i].a, &segs[i].b);
  }
  sort(segs, segs + m, pabcomp);
  for (i = 0; i < m; i++) {
    budu[i] = 0;
    if (segs[i].a == 0) budu[i]++;
    if (i > 0) {
      tmp.b = segs[i].a;
      int lb = lower_bound(segs, segs + i, tmp, pabcomp) - segs,
          lbb = lower_bound(segs, segs + i, segs[i], pabcomp) - segs;
      if (lbb > 0)
        if (lb == 0)
          budu[i] = (budu[i] + sumbudu[lbb - 1]) % 1000000007;
        else {
          budu[i] = (budu[i] + sumbudu[lbb - 1] - sumbudu[lb - 1]);
          while (budu[i] < 0) budu[i] += 1000000007;
          budu[i] %= 1000000007;
        }
      sumbudu[i] = (sumbudu[i - 1] + budu[i]) % 1000000007;
    } else {
      sumbudu[0] = budu[0];
    }
  }
  for (i = m - 1; i >= 0 && segs[i].b == n; i--) {
    ats = (ats + budu[i]) % 1000000007;
  }
  printf("%d\n", ats);
  return 0;
}
