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

//a^b % modを求める
int64_t MODpow(int64_t a, int64_t b, int64_t mod) {
    int64_t result = 1;
    while (b) {
        if (b % 2 == 1) {
            result *= a;
            result %= mod;
        }

        b /= 2;
        a *= a;
        a %= mod;
    }

    return result;
}

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N), B(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }

    constexpr int64_t MOD = 1e9 + 7;

    int64_t zero_zero_num = 0, A_zero_num = 0, B_zero_num = 0;
    map<pair<int64_t, int64_t>, int64_t> plus_mp, minus_mp;
    for (int64_t i = 0; i < N; i++) {
        if (A[i] == 0 && B[i] == 0) {
            zero_zero_num++;
        } else if (A[i] == 0) {
            A_zero_num++;
        } else if (B[i] == 0) {
            B_zero_num++;
        } else {
            int64_t gcd_AB = gcd(A[i], B[i]);
            int64_t a = abs(A[i] / gcd_AB);
            int64_t b = abs(B[i] / gcd_AB);
            int64_t sign_A = (signbit(A[i]) ? -1 : 1);
            int64_t sign_B = (signbit(B[i]) ? -1 : 1);
            if (sign_A * sign_B == 1) {
                plus_mp[make_pair(a, b)]++;
            } else {
                minus_mp[make_pair(a, b)]++;
            }
        }
    }

    //ダメなペアの数を列挙
    vector<pair<int64_t, int64_t>> disable;
    if (A_zero_num > 0 && B_zero_num > 0) {
        assert(false);
        disable.emplace_back(A_zero_num, B_zero_num);
    }
    for (auto&[key, value] : plus_mp) {
        int64_t n = value;
        int64_t m = minus_mp[make_pair(key.second, key.first)];
        if (m == 0) {
            continue;
        }
        disable.emplace_back(n, m);
    }

    //ペアがあるものの個数について総和を取得
    int64_t pair_num = 0;
    for (auto&[n, m] : disable) {
        pair_num += n + m;
    }

    //ペアがないものでの答え
    int64_t size = N - pair_num - zero_zero_num;
    int64_t ans = (MODpow(2, size, MOD) + MOD - 1) % MOD;

    //ダメなペアを考えていく
    for (auto&[n, m] : disable) {
        int64_t n_pow = (MODpow(2, n, MOD) + MOD - 1) % MOD;
        int64_t m_pow = (MODpow(2, m, MOD) + MOD - 1) % MOD;
        int64_t nm_pow = (MODpow(2, n + m, MOD) + MOD - 1) % MOD;
        int64_t sub = n_pow * m_pow % MOD * (ans + 1) % MOD;

        (ans += nm_pow * (ans + 1) % MOD) %= MOD;
        (ans += MOD - sub) %= MOD;

        size += n + m;
    }

    //(0, 0)を足す
    if (zero_zero_num) {
        size += zero_zero_num;
        ans += zero_zero_num;
    }

    assert(size == N);

    cout << ans << endl;
}