#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = ll(b) - 1; i >= (a); i--)
#define TR(X)                                                  \
    ({                                                         \
        if (1) cerr << "TR: " << (#X) << " = " << (X) << endl; \
    })
#define LL(name) \
    ll name;     \
    cin >> name;
#define VL(name, num) \
    vl name(num);     \
    FOR(INPUT_VL_I, 0, num) { cin >> name[INPUT_VL_I]; }

constexpr ll MOD = 1000000007;

ll exp(ll a, ll n) {
    ll res = 1;
    for (ll acc = a; n; acc = (acc * acc) % MOD, n >>= 1) {
        if (n & 1) {
            res = (res * acc) % MOD;
        }
    }
    return res;
}

struct binom {
    vl fac, ifac;
    binom(ll N) : fac(N + 1), ifac(N + 1) {
        fac[0] = 1;
        FOR(i, 1, N + 1) fac[i] = (fac[i - 1] * i) % MOD;
        ifac[N] = exp(fac[N], MOD - 2);
        FORD(i, 0, N) ifac[i] = (ifac[i + 1] * (i + 1)) % MOD;
    }

    ll get(ll n, ll k) {
        return (((fac[n] * ifac[k]) % MOD) * ifac[n - k]) % MOD;
    }
};

pll getNormal(pll p) {
    if (p.yy < 0) {
        return {-p.xx, -p.yy};
    } else {
        return p;
    }
}

int main() {
    cin.sync_with_stdio(0);
    LL(N);

    binom b(N + 1);

    vl As(N), Bs(N);
    FOR(i, 0, N) cin >> As[i] >> Bs[i];

    map<pll, ll> cnt;

    FOR(i, 0, N) {
        ll g = gcd(As[i], Bs[i]);

        ll na = As[i] / g;
        ll nb = Bs[i] / g;

        cnt[getNormal(mp(na, nb))]++;
    }

    ll ans = 1;
    for (auto it : cnt) {
        if (it.yy == 0) continue;

        TR(it.xx.xx);
        TR(it.xx.yy);
        TR(it.yy);

        ll factora = 0;
        FOR(k, 1, it.yy+1) {
            factora += b.get(it.yy, k);
            factora %= MOD;
        }

        pll other = getNormal(mp(-it.xx.yy, it.xx.xx));

        TR(other.xx);
        TR(other.yy);
        TR(cnt[other]);

        ll factorb = 0;
        FOR(k, 1, cnt[other]+1) {
            factorb += b.get(cnt[other], k);
            factorb %= MOD;
        }
        cnt[other] = 0;

        TR(factora);
        TR(factorb);

        ans = (ans * ((factora + 1ll + factorb)%MOD)) % MOD;
        TR(ans);
    }

    cout << (ans - 1) << endl;
}  // cin.tie(0) bei schnellem Wechseln
