#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

mint kaijou(mint x) {
	int xx = x;
	if (xx == 0 || xx == 1) return 1;
	return x * kaijou(x - 1);
}
int main() {
	int n;
	cin >> n;
	mint m = n;
	map<double, mint> mp;
	vector<int> cnt(n);
	mint ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	rep(i, n) {
		ll a, b;
		cin >> a >> b;
		if (a == 0 || b == 0) mp[0]= mp[0] + 1;
		mp[a / b] = mp[a/b]+1;mp[-b/a]=mp[-b/a] + 1;
	}
	auto begin = mp.begin(), end = mp.end();
	mint sa = 0;
	for (auto iter = begin; iter != end; iter++) {
		mint r = iter->second;
		int rn = r;
		if (rn >= 2) {
			sa = sa + kaijou(m - r);
		}
	}
	cout << ans - sa;
}

