#include <bits/stdc++.h>
using namespace std;
int dp[200010], a[200010];
pair<int, int> p[200010];
int tree[200010 << 2];
inline void pushUp(int rt) {
  tree[rt] = tree[rt << 1] + tree[rt << 1 | 1];
  if (tree[rt] >= 1000000007) tree[rt] -= 1000000007;
}
void update(int x, int val, int L, int R, int rt) {
  if (L == R) {
    tree[rt] += val;
    if (tree[rt] >= 1000000007) tree[rt] -= 1000000007;
  } else {
    int mid = (L + R) >> 1;
    if (x <= mid)
      update(x, val, L, mid, rt << 1);
    else
      update(x, val, mid + 1, R, rt << 1 | 1);
    pushUp(rt);
  }
}
bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
int query(int x, int y, int L, int R, int rt) {
  if (x <= L && R <= y) return tree[rt];
  int mid = (L + R) >> 1, ans = 0;
  if (x <= mid) ans += query(x, y, L, mid, rt << 1);
  if (y > mid) ans += query(x, y, mid + 1, R, rt << 1 | 1);
  if (ans >= 1000000007) ans -= 1000000007;
  return ans;
}
int main() {
  int n, m, cnt, i, j;
  while (~scanf("%d%d", &n, &m)) {
    for (i = cnt = 0; i < m; i++) {
      scanf("%d%d", &p[i].first, &p[i].second);
      a[cnt++] = p[i].first;
      a[cnt++] = p[i].second;
    }
    a[cnt++] = 0;
    a[cnt++] = n;
    sort(a, a + cnt);
    cnt = unique(a, a + cnt) - a;
    n = lower_bound(a, a + cnt, n) - a;
    memset(dp, 0, sizeof(dp));
    memset(tree, 0, sizeof(tree));
    for (i = 0; i < m; i++) {
      p[i].first = lower_bound(a, a + cnt, p[i].first) - a;
      p[i].second = lower_bound(a, a + cnt, p[i].second) - a;
    }
    sort(p, p + m, cmp);
    dp[0] = 1;
    update(0, dp[0], 0, cnt - 1, 1);
    for (i = 0; i < m; i = j) {
      for (j = i; j < m && p[i].second == p[j].second; j++) {
        dp[p[j].second] += query(p[j].first, p[j].second, 0, cnt - 1, 1);
        if (dp[p[j].second] >= 1000000007) dp[p[j].second] -= 1000000007;
      }
      update(p[i].second, dp[p[i].second], 0, cnt - 1, 1);
    }
    printf("%d\n", dp[n]);
  }
  return 0;
}
