#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
struct bun{
    ll si, bo;
    bun() {
        si = 0; bo = 1;
    }
    bun(ll a, ll b) {
        ll sign = (a / abs(a)) * (b / abs(b)); 
        ll gcd = __gcd(abs(a),abs(b));
        si = sign * abs(a) / gcd;
        bo = abs(b) / gcd;
    }
    const bool operator <(const bun &b) const {
        if (si == b.si) {
            return bo < b.bo;
        } else {
            return si < b.si;
        }
    }
};

ll mypow(ll a, ll b) {
    if (b == 0) return 1LL;
    ll ret = mypow(a, b / 2);
    ret *= ret;
    ret %= mod;
    if (b & 1) ret *= a;
    return ret % mod;
}

map<bun, ll> mp, mpr;
set<bun> used;
int n;
ll b0,a0,both0,no0;

ll p[200010];

int main() {
    p[0] = 1;
    for (int i = 1; i < 200010; i++) {
        p[i] = p[i-1] * 2;
        p[i] %= mod;
    }

    cin >> n;
    for (int i = 0; i < n; i++) {
        ll a,b;
        cin >> a >> b;
        if (b != 0 && a != 0) {
            mp[bun(a,b)]++;
            mpr[bun(b,a)]++;
        } else if (a == 0 && b == 0)
            both0++;
        else if (a == 0)
            a0++;
        else if (b == 0)
            b0++;
    }
    no0 = n - b0 - a0 - both0;
    
    ll sum = 1;
    for (auto mpp: mp) {
        bun b = mpp.first;
        if (used.count(b)) continue;
        bun rb = bun(-b.bo,b.si);
        // cout << b.si << "/" << b.bo << endl;
        // cout << rb.si << "/" << rb.bo << endl;
        if (mp.count(rb) != 0) {
            // cout << b.si << "/" << b.bo << "->" << (p[mpp.second] + p[mp[rb]] - 1 + mod) % mod << endl;
            used.insert(rb);
            // cout << "  used " << rb.si << "/" << rb.bo << endl;
            sum *= (p[mpp.second] + p[mp[rb]] - 1 + mod) % mod;
        } else {
            sum *= p[mpp.second];
            // cout << b.si << "/" << b.bo << "->" << p[mpp.second] << endl;
        }
    }
    sum = (sum - 1 + mod) % mod;

    ll ans = both0;
    ans += (p[b0] - 1 + mod) % mod * (sum + 1) % mod;
    ans %= mod;
    ans += (p[a0] - 1 + mod) % mod * (sum + 1) % mod;
    ans %= mod;
    ans += sum;
    ans %= mod;

    cout << ans << endl;
    return 0;
}