#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 200005;
struct node {
  int x, y;
  void fun(int a, int b) {
    x = a;
    y = b;
  }
} pnt[N];
vector<int> adj[N], arr;
int dyn[N], dp(int);
int main() {
  int n, m, imin = 1 << 30;
  cin >> n >> m;
  set<int> scatter;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    pnt[i].fun(a, b);
    scatter.insert(a);
    scatter.insert(b);
    imin = min(imin, min(a, b));
  }
  set<int>::iterator it;
  for (it = scatter.begin(); it != scatter.end(); it++) arr.push_back((*it));
  for (int i = 0; i < m; i++) {
    int a = lower_bound(arr.begin(), arr.end(), pnt[i].x) - arr.begin();
    int b = lower_bound(arr.begin(), arr.end(), pnt[i].y) - arr.begin();
    adj[b].push_back(a);
  }
  int ind = lower_bound(arr.begin(), arr.end(), n) - arr.begin();
  memset(dyn, -1, sizeof(dyn));
  if (imin == 0)
    dyn[0] = 1;
  else
    dyn[0] = 0;
  dp(ind);
  cout << (dyn[ind] - dyn[ind - 1] + mod) % mod << endl;
  return 0;
}
int dp(int ind) {
  if (dyn[ind] != -1)
    return dyn[ind];
  else {
    dyn[ind] = 0;
    for (int i = 0; i < (int)adj[ind].size(); i++) {
      int tmp = adj[ind][i] - 1;
      dyn[ind] = (dyn[ind] + dp(ind - 1)) % mod;
      if (tmp >= 0) dyn[ind] = (dyn[ind] - dp(tmp) + mod) % mod;
    }
    dyn[ind] = (dyn[ind] + dp(ind - 1)) % mod;
    return dyn[ind];
  }
}
