#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 100005;
struct A {
  int x, y;
} a[N];
int f[N], s[N];
bool cmp(const A &a, const A &b) { return a.y < b.y; }
int bs1(int l, int r, int v) {
  int m;
  while (l < r) {
    m = (l + r) / 2;
    if (a[m].y < v)
      l = m + 1;
    else
      r = m;
  }
  if (a[l].y >= v)
    return l;
  else
    return -1;
}
int bs2(int l, int r, int v) {
  int m, res = -1;
  while (l <= r) {
    m = (l + r) / 2;
    if (a[m].y < v) {
      res = max(res, m);
      l = m + 1;
    } else
      r = m - 1;
  }
  return res;
}
int main() {
  int n, m, i, l, r, ans;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) scanf("%d%d", &a[i].x, &a[i].y);
  sort(a + 1, a + m + 1, cmp);
  a[0].x = a[0].y = 0;
  f[0] = s[0] = 1;
  for (i = 1; i <= m; i++) {
    l = bs1(0, i - 1, a[i].x);
    r = bs2(0, i - 1, a[i].y);
    if (l != -1 && r != -1 && l <= r) {
      if (l - 1 < 0)
        f[i] = s[r];
      else
        f[i] = ((s[r] - s[l - 1]) % mod + mod) % mod;
    } else
      f[i] = 0;
    s[i] = (s[i - 1] + f[i]) % mod;
  }
  ans = 0;
  for (i = 1; i <= m; i++)
    if (a[i].y == n) ans = (ans + f[i]) % mod;
  printf("%d\n", ans);
}
