#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//a^n mod p
//n > 0
//#include <cmath>
long long modpow(long long a, long long n, long long p) {
	a %= p;
	if (a == 0) return 0;
	if (a == 1) return 1;
	long long b = 1, cnt = 0;
	while (b < p && cnt < n) {
		b *= a;
		cnt++;
	}
	if (b < p) return b;
	b %= p;
	return modpow(b, n / cnt, p) * (long long)pow(a, n % cnt) % p;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vll a(n), b(n);
	ll cnt_zero = 0;
	map<vll, ll> mp;
	for (ll i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		if (a[i] == 0 && b[i] == 0) cnt_zero++;
		else if (a[i] == 0) b[i] = 1;
		else if (b[i] == 0) a[i] = 1;
		else {
			bool x = (a[i] > 0), y = (b[i] > 0);
			a[i] = abs(a[i]);
			b[i] = abs(b[i]);
			ll z = __gcd(a[i], b[i]);
			a[i] /= z;
			b[i] /= z;
			if (x ^ y) a[i] *= -1;
		}
		mp[{a[i], b[i]}]++;
	}

	//for (ll i = 0; i < n; i++) cout << a[i] << " " << b[i] << endl;

	vector<vll> v(0);
	ll cnt_ban = 0;
	for (auto i = mp.begin(); i != mp.end(); i++) {
		vll x = (i -> first);
		ll y = (i -> second);
		if (x[0] < 0) continue;
		ll z = mp[{- x[1], x[0]}];
		if (z) {
			v.push_back({y, z});
			cnt_ban += y + z;
		}
	}

	ll ans = modpow(2, n - cnt_ban - cnt_zero, p);
	for (ll i = 0; i < v.size(); i++) {
		ans *= (modpow(2, v[i][0], p) + modpow(2, v[i][1], p) - 1) % p;
		ans %= p;
	}
	if (cnt_zero) {
		ans *= 2;
		ans %= p;
	}
	ans--;
	if (ans < 0) ans += p;
	cout << ans << endl;
}
