#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1e9 + 7;
long long n, m, ans, sum[100005], dp[100005];
struct node {
  long long s, t;
  friend bool operator<(node a, node b) {
    if (a.t == b.t) return a.s < b.s;
    return a.t < b.t;
  }
} c[100005];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) cin >> c[i].s >> c[i].t;
  sort(c + 1, c + m + 1);
  dp[0] = 1;
  sum[0] = 1;
  for (int i = 1; i <= m; i++) {
    int l = 0, r = i, mid, tl = 1, tr = 0;
    while (l <= r) {
      mid = (l + r) >> 1;
      if (c[mid].t >= c[i].s) {
        tl = mid;
        r = mid - 1;
      } else
        l = mid + 1;
    }
    l = 0;
    r = i;
    while (l <= r) {
      mid = (l + r) >> 1;
      if (c[mid].t < c[i].t) {
        tr = mid;
        l = mid + 1;
      } else
        r = mid - 1;
    }
    if (tl == 0)
      dp[i] = sum[tr] % Mod;
    else
      dp[i] = (sum[tr] - sum[tl - 1] + Mod) % Mod;
    sum[i] = (sum[i - 1] + dp[i]) % Mod;
  }
  for (int i = 1; i <= m; i++)
    if (c[i].t == n) ans = (ans + dp[i]) % Mod;
  cout << ans;
}
