#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
ll ex(ll a,ll b){ll ans=1;while(b){if(b&1)ans=(ans*a)%md;a=(a*a)%md,b/=2;}return ans;} 
inline ll add(ll a,ll b){a=a%md+b%md;if(a>md)a%=md;return a;}
inline ll sub(ll a,ll b){a=a%md-b%md;if(a<0)a+=md;return a;}
inline ll mul(ll a,ll b){return (a*b)%md;}

#define M 100010

int main(){
	IOS;
	tihs;

	ll n;cin>>n;
	map<pii,ll>mp;
	ll xx=0;
	rep(i,0,n){
		ll a,b;cin>>a>>b;
		if(b<0){
			b=abs(b),a*=-1;
		}
		if(!a and !b){xx++;continue;}
		if(!a)b=1;
		if(!b)a=1;
		ll g=__gcd(a,b);
		a/=g,b/=g;
		mp[{a,b}]++;
	}
	ll ans=1;
	vector<pii>v;
	while(1){
		auto it1=mp.begin();
		if(it1==mp.end())break;
		pii p=it1->fi;	mp.erase(it1);
		ll a=p.se,b=p.fi;
		if(b<0)b=abs(b),a*=-1;
		a*=-1;
		if(!a)b=1;
		if(!b)a=1;
		auto it=mp.find({a,b});
		if(it==mp.end())v.pb({ex(2,it1->se),0});
		else {
			v.pb({ex(2,it1->se),ex(2,it->se)-1});
			mp.erase(it);
		}
	}
	for(auto p:v)ans=mul(ans,add(p.fi,p.se));
	ans=sub(ans,1);
	ans=add(ans,xx);
	cout<<ans;
	return 0;
}