#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

template<int M>
struct ModInt {
public:
	using value_type = long long;
	
	ModInt(value_type val = 0) : val(val < 0 ? (M - (-val % M)) % M : val % M) {}
	
	explicit operator bool() const noexcept { return val; }
	bool operator ==(const ModInt & rhs) const noexcept { return val == rhs.val; }
	bool operator !=(const ModInt & rhs) const noexcept { return !(*this == rhs); }
	ModInt operator +() const noexcept { return ModInt(*this); }
	ModInt operator -() const noexcept { return ModInt(0) -= *this; }
	ModInt operator +(const ModInt & rhs) const noexcept { return ModInt(*this) += rhs; }
	ModInt operator -(const ModInt & rhs) const noexcept { return ModInt(*this) -= rhs; }
	ModInt operator *(const ModInt & rhs) const noexcept { return ModInt(*this) *= rhs; }
	ModInt operator /(const ModInt & rhs) const noexcept { return ModInt(*this) /= rhs; }
	
	ModInt & operator +=(const ModInt & rhs) noexcept {
		val += rhs.val;
		if (val >= M) val -= M;
		return *this;
	}
	ModInt & operator -=(const ModInt & rhs) noexcept {
		if (val < rhs.val) val += M;
		val -= rhs.val;
		return *this;
	}
	ModInt & operator *=(const ModInt & rhs) noexcept {
		val = val * rhs.val % M;
		return *this;
	}
	ModInt & operator /=(const ModInt & rhs) noexcept {
		*this *= rhs.inverse();
		return *this;
	}
	
	ModInt pow(value_type n) const {
		ModInt res = 1, x = val;
		if (n < 0) { x = x.inverse(); n = -n; }
		while (n) { if (n & 1) res *= x; x *= x; n >>= 1; }
		return res;
	}
	
	ModInt inverse() const {
		long long a = val, a1 = 1, a2 = 0, b = M, b1 = 0, b2 = 1;
		while (b > 0) {
			value_type q = a / b, r = a % b;
			value_type nb1 = a1 - q * b1, nb2 = a2 - q * b2;
			a = b; b = r;
			a1 = b1; b1 = nb1;
			a2 = b2; b2 = nb2;
		}
		assert(a == 1);
		return a1;
	}
	
	const value_type & get() const noexcept { return val; }
	static decltype(M) get_mod() noexcept { return M; }
	
	friend std::ostream & operator <<(std::ostream & os, const ModInt & rhs) { return os << rhs.val; }
	friend std::istream & operator >>(std::istream & is, ModInt & rhs) {
		value_type x;
		is >> x;
		rhs = ModInt(x);
		return is;
	}
private:
	value_type val;
};
using mint = ModInt<MOD>;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main() {
	int N;
	cin >> N;
	
	vector<ll> A(N), B(N), C(N);
	REP(i, N) {
		scanf("%lld %lld", &A[i], &B[i]);
		C[i] = (A[i] > 0) ^ (B[i] > 0);
		A[i] = abs(A[i]);
		B[i] = abs(B[i]);
		
		if (A[i] > 0 && B[i] > 0) {
			ll g = gcd(A[i], B[i]);
			A[i] /= g;
			B[i] /= g;
		}
	}
	
	int a0 = 0, b0 = 0, ab0 = 0;
	using pll = pair<ll, ll>;
	map<pll, int> mm;
	REP(i, N) {
		if (A[i] == 0 && B[i] == 0) ++ab0;
		else if (A[i] == 0) ++a0;
		else if (B[i] == 0) ++b0;
		else ++mm[pll((C[i] ? -1 : 1) * A[i], B[i])];
	}
	
	mint ans = 1;
	int sum = ab0 + a0 + b0;
	for (const auto &cur : mm) {
		ll a = abs(cur.fi.fi);
		ll b = cur.fi.se;
		int c = cur.fi.fi <= 0;
		if (c) continue;
		auto it = mm.find(pll(-b, a));
		int cnt = it == mm.end() ? 0 : it->se;
		ans *= (mint(2).pow(cur.se) - 1) + (mint(2).pow(cnt) - 1) + 1;
		sum += cur.se + cnt;
	}
	ans *= (mint(2).pow(a0) - 1) + (mint(2).pow(b0) - 1) + 1;
	ans *= mint(2).pow(N - sum);
	ans = ans - 1 + ab0;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 20364