#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
//istringstream iss(sentence);
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
  
const int biggg = 2000000000;
const long long bigggest = 1000000000000000000LL;
const double eps = .0000000001;

map<pair<long long, long long>, int> fam[2];
map<pair<long long, long long>, int> rfam[2];

long long modpow(long long x, long long n) { 
  if (n == 0) return 1LL%mod; 
  long long u = modpow(x,n/2LL); 
 
  u = (long long)(u*u)%mod; 
  if (n%2LL == 1) u = (long long)(u*x)%mod; 
  return u;
}

int main(){
    prep();
    
    set<pair<long long, long long> > families;
    int n;
    cin >> n;
    long long zeroleft = 0;
    long long zeroright = 0;
    int just0 = 0;
    for (int i=0; i<n; i++){
        long long a, b;
        cin >> a >> b;
        int odds = ((a < 0)+(b < 0))%2;
        if (a == 0 || b == 0){
            if (a == 0 && b == 0){
                just0++;
                continue;
            }
            if (a == 0) zeroleft++;
            else zeroright++;
            continue;
        }
        long long gcdd = __gcd(abs(a), abs(b));
        long long newa = abs(a)/gcdd;
        long long newb = abs(b)/gcdd;
        if (newa > newb) rfam[odds][{newb, newa}]++;
        else fam[odds][{newa, newb}]++;
        families.emplace(min(newa, newb), max(newa, newb));
    }
    long long res = 1;
    for (pair<long long, long long> p : families){
        long long oddrev = rfam[1][p];
        long long evrev = rfam[0][p];
        long long odd = fam[1][p];
        long long ev = fam[0][p];
        /*cout << oddrev << " " << evrev << " " << odd << " " << ev << endl;
        cout << p.first << " " << p.second << endl;*/
        long long tot = modpow(2, oddrev+evrev+odd+ev);
        if (p.first == p.second){
            long long one = (modpow(2, ev)-1)*(modpow(2, odd)-1);
            tot -= one;
        }else if (p.first != 0 && p.second != 0){
            long long one = mymod((modpow(2, ev)-1)*(modpow(2, oddrev)-1)+1);
            long long two = mymod((modpow(2, evrev)-1)*(modpow(2, odd)-1)+1);
            tot -= mymod(one*two-1);
        }

        tot = mymod(tot);
        res *= tot;
        res = mymod(res);
    }
    //cout << zeroleft << " " << zeroright << endl;
    long long zeroes = mymod(modpow(2, zeroleft+zeroright)-mymod((modpow(2, zeroleft)-1)*(modpow(2, zeroright)-1)));
    cout << mymod((res*zeroes)-1+just0);
}