#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

template<typename T>
constexpr T Abs(T a) {
  return a > 0 ? a : -a;
}

template<int MOD> struct Modint {
  long long val;
  constexpr Modint(long long v = 0) noexcept : val(v% MOD) {
    if (val < 0) val += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr Modint operator - () const noexcept {
    return val ? MOD - val : 0;
  }
  constexpr Modint operator + (const Modint& r) const noexcept { return Modint(*this) += r; }
  constexpr Modint operator - (const Modint& r) const noexcept { return Modint(*this) -= r; }
  constexpr Modint operator * (const Modint& r) const noexcept { return Modint(*this) *= r; }
  constexpr Modint operator / (const Modint& r) const noexcept { return Modint(*this) /= r; }
  constexpr Modint& operator += (const Modint& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Modint& operator -= (const Modint& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Modint& operator *= (const Modint& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Modint& operator /= (const Modint& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator == (const Modint& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator != (const Modint& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator << (ostream& os, const Modint<MOD>& x) noexcept {
    return os << x.val;
  }
  friend constexpr Modint<MOD> modpow(const Modint<MOD>& a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }

  friend constexpr Modint<MOD> Ncr(Modint<MOD> a, int n) {
    Modint<MOD> p = 1, q = 1;

    while (n > 0) {
      p *= a;
      a -= 1;
      q *= n--;
    }

    return p / q;
  }
};
template<int MOD>
using mint = Modint<MOD>;

constexpr int MOD = 1e9 + 7; // 1e9 + 7

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  unordered_map<i64, unordered_map<i64, int>> mp;

  mint<MOD> result = 0;// modpow(mint<MOD>(2), N) - 1;

  int free = N; // 無所属

  int zz = 0;


  F0R(i, N) {
    i64 a, b;
    cin >> a >> b;

    if (a != 0 && b != 0) {
      i64 g;
      g = gcd(Abs(a), Abs(b));
      a /= g; b /= g;
    }
    else {
      if (a != 0) a = 1;
      else if (b != 0) b = 1;
      else {
        zz++;
        free--;
        continue;
      }
    }

    if (b < 0) {
      b = -b;
      a = -a;
    }
    else if (b == 0 && a < 0) {
      a = -a;
    }

    mp[a][b]++;
    //cout << a << "," << b << newl;
  }

  vector<pair<int, int>> ps;

  for (auto& p1 : mp) {
    for (auto& p2 : p1.second) {
      i64 a = p1.first, b = p2.first;

      if (mp[a][b] == 0) continue;
      //cout << a << "," << b << newl;

      i64 c = a;
      a = -b;
      b = c;

      if (b < 0) {
        b = -b;
        a = -a;
      }
      else if (b == 0 && a < 0) {
        a = -a;
      }
      //cout << a << "," << b << newl;

      auto it = mp.find(a);
      if (it != mp.end()) {
        auto it2 = it->second.find(b);
        if (it2 != it->second.end()) {
          if (mp[a][b] != 0) {

            ps.emplace_back(mp[a][b], mp[p1.first][p2.first]);
            free -= mp[a][b] + mp[p1.first][p2.first];
            mp[a][b] = 0;
            mp[p1.first][p2.first] = 0;
          }
        }
      }
    }
  }

  //debug(free);

  result = modpow(mint<MOD>(2), free);

  for (auto p : ps) {
    mint<MOD> a = modpow(mint<MOD>(2), p.first) - 1;
    mint<MOD> b = modpow(mint<MOD>(2), p.second) - 1;

    //debug(a.val);
    //debug(b.val);
    result *= a + b + 1;
  }

  result-=1;
  result += zz;

  cout << result.val;
}
#endif


Measured memory_bytes: 33336