#include <bits/stdc++.h>
using namespace std;
struct fastIO {
  inline fastIO operator>>(int& num) {
    num = 0;
    char c = getchar();
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    bool foo = 0;
    if (c == '-') {
      foo = 1;
      c = getchar();
    }
    while (c >= '0' && c <= '9') {
      num = (num << 3) + (num << 1) + c - '0';
      c = getchar();
    }
    if (foo) num = -num;
    return *this;
  }
  inline fastIO operator>>(long long& num) {
    num = 0;
    char c = getchar();
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    bool foo = 0;
    if (c == '-') {
      foo = 1;
      c = getchar();
    }
    while (c >= '0' && c <= '9') {
      num = (num << 3) + (num << 1) + c - '0';
      c = getchar();
    }
    if (foo) num = -num;
    return *this;
  }
  inline fastIO operator>>(float& num) {
    scanf("%f", &num);
    return *this;
  }
  inline fastIO operator>>(double& num) {
    scanf("%lf", &num);
    return *this;
  }
  inline fastIO operator>>(long double& num) {
    scanf("%Lf", &num);
    return *this;
  }
  inline fastIO operator>>(char& num) {
    num = getchar();
    while (num == ' ' || num == '\n') num = getchar();
    return *this;
  }
  inline fastIO operator>>(char* num) {
    int cnt = 0;
    char c = getchar();
    while (c == ' ' || c == '\n') c = getchar();
    while (c != ' ' && c != '\n') {
      num[cnt++] = c;
      c = getchar();
    }
    num[cnt] = 0;
    return *this;
  }
  inline fastIO operator>>(string& num) {
    cin >> num;
    return *this;
  }
  inline void printInt(const int& num) {
    if (num < 10) {
      putchar(num + '0');
      return;
    }
    printInt(num / 10);
    putchar((num % 10) + '0');
  }
  inline void printINT(const long long& num) {
    if (num < 10) {
      putchar(num + '0');
      return;
    }
    printINT(num / 10);
    putchar((num % 10) + '0');
  }
  inline fastIO operator<<(const int& num) {
    if (num < 0)
      putchar('-'), printInt(-num);
    else
      printInt(num);
    return *this;
  }
  inline fastIO operator<<(const long long& num) {
    if (num < 0)
      putchar('-'), printINT(-num);
    else
      printINT(num);
    return *this;
  }
  inline fastIO operator<<(const float& num) {
    printf("%.10f", num);
    return *this;
  }
  inline fastIO operator<<(const double& num) {
    printf("%.16lf", num);
    return *this;
  }
  inline fastIO operator<<(const long double& num) {
    printf("%.20Lf", num);
    return *this;
  }
  inline fastIO operator<<(const char& num) {
    putchar(num);
    return *this;
  }
  inline fastIO operator<<(const char* num) {
    for (int i = 0; num[i]; i++) putchar(num[i]);
    return *this;
  }
  inline fastIO operator<<(const string& num) {
    cout << num;
    return *this;
  }
} fio;
struct {
  int dt[200005];
  void add(int a, int x) {
    a++;
    while (a < 200005) {
      dt[a] = (dt[a] + x) % 1000000007;
      a += (a & -a);
    }
  }
  int sum(int a) {
    a++;
    int ans = 0;
    while (a) {
      ans = (ans + dt[a]) % 1000000007;
      a -= (a & -a);
    }
    return ans;
  }
} bit;
int n, m;
int s[100005], t[100005];
map<int, int> fff;
vector<pair<int, int> > fu;
int cntfff;
int main() {
  fio >> n >> m;
  for (int i = 0; i < m; i++) {
    fio >> s[i] >> t[i];
    fff[s[i]];
    fff[t[i]];
  }
  fff[0];
  fff[n];
  for (__typeof(fff.begin()) it = fff.begin(); it != fff.end(); it++) {
    it->second = cntfff++;
  }
  n = cntfff;
  for (int i = 0; i < m; i++) {
    s[i] = fff[s[i]];
    t[i] = fff[t[i]];
    fu.push_back(make_pair(t[i], s[i]));
  }
  sort((fu).begin(), (fu).end());
  bit.add(0, 1);
  for (pair<int, int> i : fu) {
    bit.add(i.first,
            (bit.sum(i.first - 1) - bit.sum(i.second - 1) + 1000000007) %
                1000000007);
  }
  fio << (bit.sum(cntfff - 1) - bit.sum(cntfff - 2) + 1000000007) % 1000000007
      << '\n';
  return 0;
}
