#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
const int maxN = 2e5 + 7;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;

inline int pls(int x, int y) { return (x += y) >= mod ? x - mod : x; }
inline int mns(int x, int y) { return (x -= y) < mod ? x : x + mod; }
inline int mul(int x, int y) { return 1LL * x * y % mod; }
inline void Add(int &x, int y) { x = pls(x, y); }
inline void Mul(int &x, int y) { x = mul(x, y); }
inline void Minus(int &x, int y) { x = mns(x, y); }

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n, m;
struct Rec {
	int x, v;
	inline bool operator < (const Rec &v) const { return x < v.x; }
}a[maxN];
int speed[maxN];
int low[maxN], hig[maxN]; 

namespace Seg {
	const int maxP = 524297;
	#define lc (x << 1)
	#define rc (x << 1 | 1)

	int sum[maxP], tag[maxP];

	inline void pushup(int x) { sum[x] = pls(sum[lc], sum[rc]); }
	inline void totag(int x, int d) { Mul(sum[x], d), Mul(tag[x], d); }
	inline void pushdown(int x) {
		if (tag[x] != 1) {
			totag(lc, tag[x]);
			totag(rc, tag[x]);
			tag[x] = 1;
		}
	}

	int getsum(int x, int l, int r, int tl, int tr) {
		if (tl <= l && r <= tr) return sum[x];
		pushdown(x); int mid = (l + r) >> 1;
		if (tr <= mid) return getsum(lc, l, mid, tl, tr);
		if (mid < tl) return getsum(rc, mid+1, r, tl, tr);
		return pls(getsum(lc, l, mid, tl, mid), getsum(rc, mid+1, r, mid+1, tr));
	}

	void plus(int x, int l, int r, int to, int d) {
		if (l == r) { Add(sum[x], d); return; }
		pushdown(x); int mid = (l + r) >> 1;
		if (to <= mid) plus(lc, l, mid, to, d);
		else plus(rc, mid+1, r, to, d);
		pushup(x);
	}

	void mult(int x, int l, int r, int tl, int tr, int d) {
		if (tl <= l && r <= tr) { totag(x, d); return; }
		pushdown(x); int mid = (l + r) >> 1;
		if (tl <= mid) mult(lc, l, mid, tl, tr, d);
		if (mid < tr) mult(rc, mid+1, r, tl, tr, d);
		pushup(x);
	}
	
	inline void init() { For (i, 1, maxP) tag[i] = 1; }
	inline int getsum(int l, int r) { return getsum(1, 0, m, l, r); }
	inline void plus(int to, int d) { plus(1, 0, m, to, d); }
	inline void mult(int l, int r, int d) { mult(1, 0, m, l, r, d); }

	#undef lc
	#undef rc
}

int main() {

	n = ri();
	rep (i, 1, n) a[i].x = ri(), speed[i] = a[i].v = ri();
	sort(speed+1, speed+n+1); m = unique(speed+1, speed+n+1) - (speed+1);
	sort(a+1, a+n+1);
	rep (i, 1, n) a[i].v = lower_bound(speed+1, speed+m+1, a[i].v) - speed;
	low[n+1] = INF, hig[n+1] = -INF;
	per (i, n, 1) low[i] = min(low[i+1], a[i].v), hig[i] = max(hig[i+1], a[i].v);

	int cur = 0;
	Seg::init();
	Seg::plus(0, 1);
	rep (i, 1, n) {
		cur = max(cur, a[i].v);
		int t = Seg::getsum(low[i]-1, cur);
		Seg::plus(cur, t);
	}
	printf("%d\n", Seg::getsum(m, m));
/*
	rep (i, 1, n) {
		int t = Seg::getsum(low[i]-1, a[i].v);
		Seg::plus(a[i].v, t);
		Add(res, Seg::getsum(hig[i], m)); 
		if (a[i].v != m) Seg::mult(a[i].v+1, m, 2);
	}
	printf("%d\n", res);
*/
	return 0;
}


Measured memory_bytes: 8192