#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

ll bm(ll b, ll p, ll m) {
	ll r = 1;
	for (; p; p >>= 1, b = b * b % m) if (p & 1) r = r * b % m;
	return r;
}

void simp(ll &a, ll &b) {
	if (a == 0) a = 0, b = 1;
	else if (b == 0) a = 1, b = 0;
	else {
		if (b < 0) a = -a, b = -b;
		ll g = __gcd(abs(a), abs(b));
		a /= g, b /= g;
	}
}

pair<ll, ll> inv(ll a, ll b) {
	ll g = -b, h = a;
	simp(g, h);
	return {g, h};
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll n; cin >> n;
	map<pair<int, int>, ll> m;

	ll worst = 0;

	rep(i, 0, n) {
		ll a, b; read(a, b);
		if (!a && !b) {
			worst++;
			continue;
		}
		simp(a, b);
		m[{a, b}]++;
	}
	
	const ll mod = 1000000007;
	ll ans = 1;

	vector<pair<pii, int>> v(all(m));
	for (auto a : v) {
		pair<int, int> p = a.first;
		pair<int, int> iv = inv(p.first, p.second);
		ll freq = m[p];
		ll freq2 = m[iv];

		m[p] = 0;
		m[iv] = 0;
		
		if (!freq2) {
			//write("SG", p.first, p.second, freq, bm(2, freq, mod));
			ans = (ans * bm(2, freq, mod)) % mod;
		} else {
			//write("DB", p.first, p.second, freq, freq2, bm(2, freq, mod) + bm(2, freq2, mod) - 1);
			ans = (ans * ((bm(2, freq, mod) + bm(2, freq2, mod) - 1))) % mod;
		}

		//write(a.first.first, a.first.second, inv(a.first.first, a.first.second).first, inv(a.first.first, a.first.second).second, a.second);
	}

	ans = (ans + mod - 1) % mod;
	ans = (ans + worst) % mod;

	write(ans);
}
