#include <bits/stdc++.h>
using namespace std;
const long long MOD=1e9+7;
map<pair<long long, long long>, long long>mp;
map<pair<long long, long long>, bool>done;
long long modpow(long long x,long long e){
	if(x==1||e==0) return 1;
	long long c=modpow(x,e/2);
	long long c1=(c*c)%MOD;
	if(e%2==0) return c1;
	else return (c1*x)%MOD;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	set<pair<int, int>>s;
	for(int i=1;i<=n;i++){
		long long a, b;
		cin>>a>>b;
		long long g=__gcd(a, b);
		mp[{-a/g, -b/g}]++;
		mp[{a/g, b/g}]++;
		s.insert({a/g, b/g});
	}
	long long fans=1;
	for(auto p:s){
		if(done[p]) continue;
		long long ans=modpow(2, mp[p])+modpow(2, mp[{-p.second, p.first}])-1;
		done[p]=true;
		done[{-p.second, p.first}]=true;
		done[{p.second, -p.first}]=true;
		done[{-p.first, -p.second}]=true;
		fans=(fans*ans)%MOD;
	}
	cout<<(fans+MOD-1)%MOD;
}