#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int,Int> p;
const Int MOD = 1e9+7;

Int power(Int a, Int n){
    if(a == 0) return 0;
    if(n == 0) return 1;
    
    Int res = 1;
    while(n > 0){
        if(n % 2 == 1) res = res * a % MOD;
        a = a * a % MOD; n /= 2;
    }
    return res;
}

int main(){ 
    Int N; cin >> N;
    map<p,p> M;
    Int cnt = 0, zero_iwashi_count = 0;

    rep(i,N){
        p now, opp;
        cin >> now.first >> now.second;
        if(now == p(0,0)){
            zero_iwashi_count++;
            continue;
        } else if (now.first == 0){
            now = p(0,1); 
            opp = p(1,0);
        } else if (now.second == 0){
            now = p(1,0);
            opp = p(0,1);
        } else {
            Int g = __gcd(abs(now.first),abs(now.second));
            now.first /= g; now.second /= g;
            if(now.first < 0) now = p(-now.first,-now.second);

            if(now.second > 0) opp = p(now.second, -now.first);
            else opp = p(-now.second, now.first);
        }

        if(M.count(opp)) M[opp].second++;
        else M[now].first++;
        cnt++;
    }

    Int ans = 1;
    for(auto x : M){
        Int X = x.second.first, Y = x.second.second;

        cout << X << " " << Y << endl;

        Int now = power(2,X) + power(2,Y) - 1; now %= MOD;
        ans = ans * now % MOD;
    }

    cout <<  (ans + zero_iwashi_count -1 ) % MOD<< endl;
}
