#include <bits/stdc++.h>
using namespace std;
long long ans, n, m, w[100100], d = 1000 * 1000 * 1000 + 7;
struct stop {
  long long s, t;
};
stop p[100100];
int binarySearch(int a, int b, int x) {
  if (a == b) return a - 1;
  int mid = (a + b) / 2;
  if (p[mid].t >= x) return binarySearch(a, mid, x);
  return binarySearch(mid + 1, b, x);
}
bool comp(stop x, stop y) { return x.t < y.t; }
int main() {
  cin >> n >> m;
  w[1] = 1;
  for (int i = 1; i < m + 1; i++) cin >> p[i + 1].s >> p[i + 1].t;
  sort(p, p + m + 2, comp);
  for (int i = 1; i < m + 1; i++)
    w[i + 1] = w[i] + w[binarySearch(1, m + 2, p[i + 1].t)] -
               w[binarySearch(1, m + 2, p[i + 1].s)],
          w[i + 1] %= d;
  int tmp = binarySearch(1, m + 2, n);
  if (p[tmp + 1].t < n)
    cout << 0 << endl;
  else
    cout << (d + w[m + 1] - w[tmp]) % d << endl;
}
