#include<bits/stdc++.h>
using namespace std;
long long n,b[200005],f;
pair<long long,long long>a[100005];
long long pw(long long x,long long y){
long long s=1;
while(y){
if(y&1) s*=x,s%=1000000007;
x*=x,x%=1000000007,y>>=1;
}
return s;
}
int main(){
freopen("usaco_Feb_help.in","r",stdin);
freopen("usaco_Feb_help.out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i].first>>a[i].second;
sort(a+1,a+n+1);
for(int i=1;i<=n;i++) b[a[i].second]++;
for(int i=1;i<=2*n;i++) b[i]+=b[i-1];
for(int i=1;i<=n;i++) f=f*2+pw(2,b[a[i].first-1]),f%=1000000007;
cout<<f;
return 0;
}