#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; i++)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#ifdef _DEBUG
#define PRE_COMMAND             \
    std::cin.rdbuf(in.rdbuf()); \
    std::cout << fixed << setprecision(15);
#else
#define PRE_COMMAND cout << fixed << setprecision(15);
#endif
const double EPS = 1e-10, PI = acos(-1.0);
template <class T> auto MAX(T& seq) {
    return *max_element(seq.begin(), seq.end());
}
template <class T> auto MIN(T& seq) {
    return *min_element(seq.begin(), seq.end());
}
template <class T> auto SUM(T& seq) {
    T temp{0};
    auto& temp2 = temp[0];
    return accumulate(seq.begin(), seq.end(), temp2);
}
template <class T> void SORT(T& seq) { sort(seq.begin(), seq.end()); }
template <class T, class S> void SORT(T& seq, S& sort_order) {
    sort(seq.begin(), seq.end(), sort_order);
}
template <class T> void SORTR(vector<T>& seq) {
    sort(seq.begin(), seq.end(), greater<T>());
}
template <class T, class S, class R> long long pow(T n_0, S k_0, R mod_0) {
    long long n = n_0, k = k_0, mod = mod_0, now = 1;
    while (true) {
        if (k & 1) { now = now * n % mod; }
        if ((k >>= 1) == 0) { return now; }
        n = (n * n) % mod;
    }
}
template <typename T> istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}

int main() {
    PRE_COMMAND
    long long n, ab_0 = 0, a_0 = 0, b_0 = 0;
    long long a, b, mod = 1000000007;
    long long c, d, e;
    long long mod2 = mod;  //とりあえず
    cin >> n;
    map<long long, long long> ab;
    vector<long long> ab_v;
    REP(i, n) {
        cin >> a >> b;
        if (a == 0 && b == 0) {
            ab_0++;
        } else if (a == 0) {
            a_0++;
        } else if (b == 0) {
            b_0++;
        } else {
            if (a < 0) a = mod2 + (a % mod2);
            if (b < 0) b = mod2 + (b % mod2);
            c = a % mod2, d = pow(b, mod2 - 2, mod2);
            e = c * d % mod2;
            if (ab.count(e)) {
                ab[e]++;
            } else {
                ab[e] = 1;
                ab_v.push_back(e);
            }
        }
    }
    long long ans = 1;
    for (long long i : ab_v) {
        if (!ab.count(i)) { continue; }
        e = (mod2 - i) % mod2;
        e = pow(e, mod2 - 2, mod2);
        long long f;
        if (ab.count(e)) {
            f = (pow(2, ab[i], mod2) + pow(2, ab[e], mod2) - 1) % mod;
        } else {
            f = pow(2, ab[i], mod2) % mod;
        }
        ab.erase(i);
        if (ab.count(e)) { ab.erase(e); }
        ans = ans * f % mod;
    }
    e = (pow(2, a_0, mod2) + pow(2, b_0, mod2) - 1) % mod;
    ans = (ans * e + ab_0 - 1 + mod) % mod;
    cout << ans << endl;
}