#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

const ull ma = (1ull << 52) - 1;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;
	pair<ull, ull> AB[200001];
	int a0 = 0, b0 = 0;
	int ab00 = 0;
	int ka = 0, kb = N - 1;
	rep(i, N) {
		ll a, b;
		cin >> a >> b;

		if (a == 0 && b == 0) {
			ab00++;
			continue;
		}
		if (a == 0) {
			a0++;
			continue;
		}
		if (b == 0) {
			b0++;
			continue;
		}

		if (a < 0) {
			a = -a;
			b = -b;
		}
		bool p = (b > 0);
		if (!p) {
			b = -b;
			swap(a, b);
		}

		int k = __builtin_clzll(a) - __builtin_clzll(b);
		if (k > 0) a <<= k;
		else b <<= -k;
		if (a > b) {
			b <<= 1;
			k--;
		}

		double d = double(b) / a;
		ull tmp1 = *(ull*)& d;
		ull c = tmp1 & ma | (1ull << 52);
		lll sa = (lll(b) << 52) - lll(a) * c;
		while (sa >= 0) {
			sa -= a;
			c++;
		}
		while (sa < 0) {
			sa += a;
			c--;
		}
		tmp1 = ull(k + 50) << 53 | c;
		b = sa;
		ull tmp2 = 0;
		if (b) {
			k = __builtin_clzll(a) - __builtin_clzll(b);
			if (k > 0) a <<= k;
			else b <<= -k;
			if (a > b) {
				b <<= 1;
				k--;
			}
			d = double(b) / a;
			tmp2 = *(ull*)& d;
			c = tmp2 & ma | (1ull << 52);
			sa = (lll(b) << 52) - lll(a) * c;
			while (sa >= 0) {
				sa -= a;
				c++;
			}
			while (sa < 0) {
				sa += a;
				c--;
			}
			tmp2 = ull(k + 50) << 53 | c;
			b = sa;
			if (b) tmp2 += a / b;
		}

		if (p) AB[ka++] = { tmp1,tmp2 };
		else AB[kb--] = { tmp1,tmp2 };
	}
	auto BA = AB + kb + 1;
	kb = N - 1 - kb;
	ll kotae = 1;
	sort(AB, AB + ka);
	sort(BA, BA + kb);
	BA[kb] = { ~(ull)0, 0 };

	pair<ull, ull> mae = AB[0];
	int p = 0;
	int kA = 0;
	rep(i, ka) {
		if (mae != AB[i]) {
			int tmp = 0;

			pair<ull, ull> mae2 = BA[p];
			int kB = 0;
			while (BA[p] <= mae) {
				if (mae2 != BA[p]) {
					kotae = kotae * modpow(2, kB) % mod;
					mae2 = BA[p];
					kB = 1;
				}
				else kB++;
				p++;
			}

			if (mae == mae2) {
				tmp = kB;
			}
			else {
				kotae = kotae * modpow(2, kB) % mod;
			}

			if (tmp) {
				kotae = kotae * (modpow(2, kA) + modpow(2, kB) - 1) % mod;
			}
			else {
				kotae = kotae * modpow(2, kA) % mod;
			}

			mae = AB[i];
			kA = 1;
		}
		else kA++;
	}

	int tmp = 0;
	pair<ull, ull> mae2 = BA[p];
	int kB = 0;
	while (p < kb) {
		if (mae2 != BA[p]) {
			if (AB[ka - 1] == mae2) {
				tmp = kB;
			}
			else {
				kotae = kotae * modpow(2, kB) % mod;
			}
			mae2 = BA[p];
			kB = 1;
		}
		else kB++;
		p++;
	}

	if (AB[ka - 1] == mae2) {
		tmp = kB;
	}
	else {
		kotae = kotae * modpow(2, kB) % mod;
	}

	if (tmp) {
		kotae = kotae * (modpow(2, kA) + modpow(2, kB) - 1) % mod;
	}
	else {
		kotae = kotae * modpow(2, kA) % mod;
	}

	kotae = kotae * (modpow(2, a0) + modpow(2, b0) - 1) % mod;

	co((kotae - 1 + ab00 + 2 * mod) % mod);

	Would you please return 0;
}