#include <bits/stdc++.h>
#define ll long long
using namespace std;
void resi(){
    int n;
    cin >> n;
    int xR, yR;
    long long manje = 1;
    long long vece = 1;
    long long mod = 1e9 + 7;
    long long ans = 0;
    vector<pair<long long ,long long>> a(n);
    for(int i=0;i<n;++i){
       cin >> a[i].first >> a[i].second;
       if(a[i].second == 1){
        xR = a[i].first;
        yR = 1;
      }
    }
   for(int i=0;i<n;++i){
      if(a[i].second != 1){
        if(a[i].first >= -(xR)){
            if(a[i].first == -(xR))
                ans++;
            manje = (manje%mod) * 2;
         }
         else{
            vece = (vece%mod) * 2;
         }
      }
   }
   ans += (manje-1)*(vece-1);
   cout << ans << '\n';
   return;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
    resi();
    return 0;
}