// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int const mxn=2e5+5;
map<ld,ii>mp;

ll modpow(ll a, ll b) // put b = mod-2, calc for (x!)^(mod-2) % mod only, [use x^(mod-2) when x^-1] 
{
	ll r=1;
	while(b)
	{
		if(b&1)r=(r*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return r;
}

void multi(ll &a, ll b){
	a%=MOD; b%=MOD; a*=b; a%=MOD; return;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll a,b,n; cin >> n;
	int zero = 0;
	for(int i=0; i<n; i++){
		cin >> a >> b;
		if(a==0&&b==0){
			zero++;
			continue;
		}
		if(a==0){
			mp[0].fi++;
			continue;
		}
		if(b==0){
			mp[0].se++;
			continue;
		}
		ll g = __gcd(a,b);
		a/=g; b/=g;
		ld now = ld(a)/b;
		mp[now].fi++;
		now = -1/now;
		mp[now].se++;
	}
	ll ans = 1LL;
	for(auto p:mp){
		if(p.fi>0)break;
		a = p.se.fi;
		b = p.se.se;
		ll now = 1LL;
		now += modpow(2,a)-1;
		now += modpow(2,b)-1;
		multi(ans,now);
	}
	ans -= 1;
	ans += zero;
	ans = (ans+MOD)%MOD;
	cout << ans << endl;
}	
