#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 100000 + 10;
const int M = 200000 + 10;
int val[M], idx = 0;
int sum[M << 2], l[N], r[N];
vector<int> g[M];
void update(int pos, int v, int l, int r, int rt) {
  if (l == r) {
    sum[rt] = (sum[rt] + v) % mod;
  } else {
    int mid = (l + r) >> 1;
    if (pos <= mid)
      update(pos, v, l, mid, rt << 1);
    else
      update(pos, v, mid + 1, r, rt << 1 | 1);
    sum[rt] = (sum[rt << 1] + sum[rt << 1 | 1]) % mod;
  }
}
int query(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) {
    return sum[rt];
  } else {
    int mid = (l + r) >> 1;
    if (L > mid)
      return query(L, R, mid + 1, r, rt << 1 | 1);
    else if (R <= mid)
      return query(L, R, l, mid, rt << 1);
    else
      return (query(L, mid, l, mid, rt << 1) +
              query(mid + 1, R, mid + 1, r, rt << 1 | 1)) %
             mod;
  }
}
int main() {
  memset(sum, 0, sizeof sum);
  int n, m, v;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &l[i], &r[i]);
    val[idx++] = l[i];
    val[idx++] = r[i];
  }
  val[idx++] = 0;
  val[idx++] = n;
  sort(val, val + idx);
  idx = unique(val, val + idx) - val;
  for (int i = 0; i < m; ++i) {
    l[i] = lower_bound(val, val + idx, l[i]) - val;
    r[i] = lower_bound(val, val + idx, r[i]) - val;
    g[r[i]].push_back(l[i]);
  }
  update(0, 1, 0, idx - 1, 1);
  for (int i = 1; i < idx; ++i)
    for (int j = 0; j < g[i].size(); ++j) {
      v = query(g[i][j], i - 1, 0, idx - 1, 1);
      update(i, v, 0, idx - 1, 1);
    }
  printf("%d\n", query(idx - 1, idx - 1, 0, idx - 1, 1));
  return 0;
}
