#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

template<typename T>
struct ST{
  using F = function<T(T, T)>;
  int size_ = 1, n_; vector<T> node; T initial; F query_, update_;
  ST(int n, T initial, F query, F update){
    while(size_ < n) size_ *= 2;
    node.resize(2*size_-1, initial);
    n_ = n;
    query_ = query;
    update_ = update;
  }
  void printnodes(){
    rep(i, node.size()) cout << node[i] << endl;
    return;
  }
  void build(vector<T> v){
    rep(i, v.size()) node[i+size_-1] = v[i];
    rrep(i, size_ - 1) node[i] = query_(node[2*i+1], node[2*i+2]);
    return;
  }
  void update(int j, T x){
    j += size_-1;
    node[j] = update_(node[j], x);
    while(j > 0){
      j = (j-1)/2;
      node[j] = query_(node[2*j+1], node[2*j+2]);
    }
    return;
  }
  T query(int l, int r){
    l += size_-1;
    r += size_-1;
    T ql = node[l], qr = node[r];
    while(l < r-1){
      if(l % 2 == 1) ql = query_(ql, node[l+1]);
      if(r % 2 == 0) qr = query_(node[r-1], qr);
      l = (l-1)/2;
      r = (r-1)/2;
    }
    return query_(ql, qr);
  }
  T entire(){
    return node[0];
  }
  int lb(T x){
    int tmp = 0;
    while(tmp < size_-1){
      if(x <= node[tmp*2+1]) tmp = tmp*2+1;
      else tmp = tmp*2+2;
    }
    if(node[tmp] < x) ++tmp;
    return min(tmp+1-size_, n_);
  }
  int ub(T x){
    int tmp = 0;
    while(tmp < size_-1){
      if(x < node[tmp*2+1]) tmp = tmp*2+1;
      else tmp = tmp*2+2;
    }
    if(node[tmp] <= x) ++tmp;
    return min(tmp+1-size_, n_);
  }
};

int main(){
  lint n, zf = 0, zs = 0, a = 0, pa = 0, ot, p = 1, q = 1, r = 1, s = 1; cin >> n;
  vector<pli> v(n), pl, mi;
  rep(i, n){
    cin >> v[i].fi >> v[i].se;
    if(v[i].fi == 0) ++zf;
    if(v[i].se == 0) ++zs;
    lint ta = abs(v[i].fi), tb = abs(v[i].se), tc = __gcd(ta, tb);
    if((v[i].fi > 0 && v[i].se > 0) || (v[i].fi < 0 && v[i].se < 0)) pl.push_back({ta/tc, tb/tc});
    else mi.push_back({ta/tc, tb/tc*(-1)});
  }
  sort(pl.begin(), pl.end());
  sort(mi.begin(), mi.end());
  auto g = [](pli a, pli b){return b;};
  pli h = {1e18, 1e18};
  ST<pli> w(mi.size(), h, g, g);
  w.build(mi);
  rep(i, pl.size()) pa += w.ub({pl[i].fi, -1*pl[i].se}) - w.lb({pl[i].fi, -1*pl[i].se});
  ot = n - zf - zs - pa*2;
  rep(i, ot){
    p *= 2;
    p %= mod1;
  }
  if(ot == 0) p = 0;
  rep(i, pa){
    q *= 3;
    q %= mod1;
  }
  if(pa = 0) q = 0;
  rep(i, zf){
    r *= 2;
    r %= mod1;
  }
  rep(i, zs){
    s *= 2;
    s %= mod1;
  }
  if(zf == 0) r = 0;
  if(zs == 0) s = 0;
  a = p + q;
  a *= r + s+ 1;
  --a;
  a %= mod1;
  return 0;
}