#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(long long i=a;i<=(b);++i)
#define dF(i,a,b) for(long long i=a;i>=(b);--i) 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 2e5+10;
const int N = 1e5+10;
const int E = 1e6+10;  
ll n,m;
ll a[maxn],b[maxn];
bool vis[maxn];
vector<int> g[maxn];
map<ll,map<ll,int> > S;
ll val[maxn];

ll qpow(ll n,ll b){
	ll res = 1;
	while(b){
		if(b&1) res= res*n%mods;
		n = n*n%mods;
		b>>=1;
	} 
	return res;
}

ll dfs(int x){
	ll ans = val[x];
	vis[x] = 1;
	for(int i=0;i<g[x].size();i++){
		if(!vis[g[x][i]]) ans+=dfs(g[x][i]);
	}
	return ans;
}

int main(){
	cin>>n;
	F(i,1,n){
		val[i] = 1;
	}
	F(i,1,n){
		cin>>a[i]>>b[i];
		if(a[i]==0&&b[i]==0){
			vis[i] = 1;
			continue;
		} 
		ll tmp = __gcd(abs(a[i]),abs(b[i]));
		a[i]/=tmp;
		b[i]/=tmp;
		if(S[a[i]][b[i]]){
			vis[i]=1;
			val[S[a[i]][b[i]]]++; 
			continue; 
		} 
		else S[a[i]][b[i]]=i;
		if(S[-b[i]][a[i]]){
			int v = S[-b[i]][a[i]];
			g[v].pb(i);
			g[i].pb(v);
		}
		if(S[b[i]][-a[i]]){
			int v = S[b[i]][-a[i]];
			g[v].pb(i);
			g[i].pb(v);
		}
	}
	ll ans = 1;
	F(i,1,n){
		if(a[i]==b[i]==0){
			ans= ans*2%mods;
			continue;
		}
		if(!vis[i]){
			int p = dfs(i);
			if(p==1){
				ans = ans*2%mods;
			} 
			else{
				if(p%2==0){
					ans = ans*(qpow(2,p/2)-1+qpow(2,p/2)-1+1)%mods;
				}
				else{
					ans = ans*(qpow(2,p/2)-1+qpow(2,p/2+1)-1+1)%mods;
				}
			}
		}
	}
	ans = (ans-1+mods)%mods;
	cout<<ans<<endl; 
}
