#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-8;
const long double PI = 3.1415926535897932384626433832795;
const int OSN = (1 << 18) - 1;
const int MOD = INF + 7;
int n, m, x[OSN], y[OSN], tree[2 * OSN + 100];
vector<int> g[OSN], X;
void update(int v, int value) {
  v += OSN;
  tree[v] = value;
  while (v > 0) {
    v = (v - 1) >> 1;
    tree[v] = (tree[2 * v + 1] + tree[2 * v + 2]) % MOD;
  }
}
int getSum(int v, int l, int r, int ll, int rr) {
  if (l > rr || ll > r || ll > rr) return 0;
  if (ll <= l && r <= rr) return tree[v];
  int mid = (l + r) >> 1;
  return (getSum(2 * v + 1, l, mid, ll, rr) +
          getSum(2 * v + 2, mid + 1, r, ll, rr)) %
         MOD;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < (int)(m); i++) {
    scanf("%d%d", &x[i], &y[i]);
    X.push_back(x[i]);
    X.push_back(y[i]);
  }
  X.push_back(0);
  X.push_back(n);
  sort(X.begin(), X.end());
  X.erase(unique(X.begin(), X.end()), X.end());
  for (int i = 0; i < (int)(m); i++) {
    x[i] = (int)(lower_bound(X.begin(), X.end(), x[i]) - X.begin());
    y[i] = (int)(lower_bound(X.begin(), X.end(), y[i]) - X.begin());
    g[y[i]].push_back(x[i]);
  }
  update(0, 1);
  for (int i = 0; i < (int)(X.size()); i++) {
    int cur = 0;
    for (int j = 0; j < (int)(g[i].size()); j++)
      cur = (cur + getSum(0, 0, OSN, g[i][j], i - 1)) % MOD;
    if (i != 0) update(i, cur);
  }
  cout << getSum(0, 0, OSN, (int)X.size() - 1, (int)X.size() - 1) << endl;
  return 0;
}
