#include <bits/stdc++.h>
using namespace std;
bool btest = 0;
const int maxn = 100011;
const int INF = (int)1e9;
struct C {
  int s, t;
} a[maxn];
int n, m, tot;
map<int, int> mp;
int p[maxn], sw[maxn], sz[maxn];
int cmp(const void *a, const void *b) { return (*(C *)a).t - (*(C *)b).t; }
int lowbit(int x) { return x & (-x); }
void add(int x, int g) {
  while (x <= n) {
    mp[x] = mp[x] + g;
    if (mp[x] > 1000000007) mp[x] -= 1000000007;
    x += lowbit(x);
  }
}
int getSum(int x) {
  int sum = 0;
  while (x > 0) {
    if (mp.count(x)) {
      sum += mp[x];
      if (sum > 1000000007) sum -= 1000000007;
    }
    x -= lowbit(x);
  }
  return sum;
}
int findPosition(int d) {
  int mid, x = tot, y = 0;
  while (x != y + 1) {
    mid = (x + y) / 2;
    if (p[mid] >= d)
      x = mid;
    else
      y = mid;
  }
}
int main() {
  ios::sync_with_stdio(0);
  int i, j;
  cin >> n >> m;
  n += 1;
  for (i = 1; i <= m; i++) {
    cin >> a[i].s >> a[i].t;
    a[i].s++;
    a[i].t++;
  }
  qsort(a + 1, m, sizeof a[0], cmp);
  add(1, 1);
  for (i = 1; i <= m; i++) {
    int sum = getSum(a[i].t - 1) - getSum(a[i].s - 1);
    while (sum > 1000000007) sum -= 1000000007;
    if (sum < 0) sum += 1000000007;
    add(a[i].t, sum);
  }
  int ans = getSum(n) - getSum(n - 1);
  if (ans < 0) ans += 1000000007;
  ans = (ans + 1000000007) % 1000000007;
  cout << ans << endl;
  return 0;
}
