#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;
const ull ma2 = (1ull << 63) - 1;
const ull ma3 = (1ull << 63);
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;
	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);
		}

		ull tmp = 0;
		rep(i, 3) {
			if (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--;
				}
				tmp += ull(k + 127) << 53 | c;
				b = sa;
			}
			tmp *= 3;
		}

		if (p) AB[i] = tmp | 1;
		else AB[i] = tmp & ~1;
	}
	sort(AB, AB + N);

	ll kotae = 1;
	ull mae = AB[0] >> 1;
	int k1 = 0, k2 = 0;
	rep(i, N) {
		if (mae != AB[i] >> 1) {
			kotae = kotae * (modpow(2, k1) + modpow(2, k2) - 1) % mod;
			k1 = 0;
			k2 = 0;
			mae = AB[i] >> 1;
		}
		if (AB[i] & 1) k1++;
		else k2++;
	}
	kotae = kotae * (modpow(2, k1) + modpow(2, k2) - 1) % mod;

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

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

	Would you please return 0;
}