#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
using uint = uint32_t;
using ulint = uint64_t;
template <class T>
using vector2d = vector<vector<T>>;
template <class T>
bool UpdateMax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  } else {
    return false;
  }
}
template <class T>
bool UpdateMin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  } else {
    return false;
  }
}
template <class T>
void OutVec(const vector<T>& vec) {
  for (int i = 0; i < vec.size() - 1; ++i) {
    cout << vec[i] << " ";
  }
  cout << vec.back() << endl;
}
template <class T>
void OutVec2d(const vector2d<T>& vec) {
  for (auto v : vec) {
    OutVec(v);
  }
}
class UnionFindForest {
  std::vector<int> parent_;
  std::vector<int> rank_;
  std::vector<int> size_;

 public:
  UnionFindForest(const int& n);
  int Root(const int& q);
  bool IsSame(const int& x, const int& y);
  void Unite(int x, int y);
  int Size(const int& q);
};
UnionFindForest::UnionFindForest(const int& n) {
  parent_.resize(n);
  rank_.resize(n);
  size_.resize(n);
  for (int i = 0; i < n; i++) {
    parent_[i] = i;
    rank_[i] = 0;
    size_[i] = 1;
  }
}
int UnionFindForest::Size(const int& q) { return size_[Root(q)]; }
int UnionFindForest::Root(const int& q) {
  if (parent_[q] == q) {
    return q;
  } else {
    return parent_[q] = Root(parent_[q]);
  }
}
bool UnionFindForest::IsSame(const int& x, const int& y) {
  return Root(x) == Root(y);
}
void UnionFindForest::Unite(int x, int y) {
  x = Root(x);
  y = Root(y);
  if (x == y) return;
  if (rank_[x] < rank_[y]) {
    parent_[x] = y;
    size_[y] += size_[x];
    size_[x] = 0;
  } else {
    parent_[y] = x;
    size_[x] += size_[y];
    size_[y] = 0;
    if (rank_[x] == rank_[y]) rank_[x]++;
  }
}
using llint = __int128;
llint gcd(llint a, llint b) { return a > 0 ? gcd(b % a, a) : b; }
struct Iwashi {
  llint a, b;
  int n;
  Iwashi(llint _a, llint _b, llint _n) : a(_a), b(_b), n(_n) {
    if (b < 0) a *= -1, b *= -1;
    llint d = gcd(a < 0 ? -a : a, b);
    if (d == 0)
      a = 0, b = 1;
    else
      a /= d, b /= d;
  }
  Iwashi() {}
  bool operator<(const Iwashi& another) const {
    return a * another.b < another.a * b;
  }
  bool operator==(const Iwashi& another) const {
    return a * another.b == b * another.a;
  }
  bool IsPositive() { return a > 0; }
};
int64_t EuclidMod(int64_t v, int64_t m) {
  if (0 <= v && v < m) {
    return v;
  } else if (-m <= v && v < 0) {
    return v + m;
  } else {
    int64_t result = v % m;
    if (result < 0) {
      result += m;
    }
    return result;
  }
}
int64_t ModInv(int64_t a, int64_t m) {
  int64_t b = m, u = 1, v = 0;
  while (b) {
    int64_t t = a / b;
    a -= t * b;
    std::swap(a, b);
    u -= t * v;
    std::swap(u, v);
  }
  EuclidMod(u, m);
  return u;
}
int64_t RepeatedPowMod(int64_t base, int64_t exponent, int64_t mod) {
  if (exponent == 0)
    return 1;
  else if (exponent % 2 == 0) {
    int64_t root = RepeatedPowMod(base, exponent / 2, mod);
    return (root * root) % mod;
  } else {
    return (base * RepeatedPowMod(base, exponent - 1, mod)) % mod;
  }
}
template <int64_t mod>
class ModInt {
  int64_t value_;

 public:
  explicit ModInt(const int64_t x = 0) : value_(x % mod){};
  ModInt& operator=(const ModInt& another) {
    value_ = another.value_;
    return *this;
  }
  ModInt& operator^=(const ModInt& another) {
    value_ = RepeatedPowMod(value_, another.value_, mod);
    return *this;
  }
  ModInt& operator+=(const ModInt& another) {
    value_ += another.value_;
    value_ = EuclidMod(value_, mod);
    return *this;
  }
  ModInt& operator-=(const ModInt& another) {
    value_ -= another.value_;
    value_ = EuclidMod(value_, mod);
    return *this;
  }
  ModInt& operator*=(const ModInt& another) {
    value_ *= another.value_;
    value_ = EuclidMod(value_, mod);
    return *this;
  }
  ModInt& operator/=(const ModInt& another) {
    value_ = value_ * ModInv(another.value_, mod);
    value_ = EuclidMod(value_, mod);
    return *this;
  }
  ModInt& operator++() {
    value_ += 1;
    value_ = EuclidMod(value_, mod);
    return *this;
  }
  ModInt operator++(int) {
    ModInt tmp = *this;
    this->value_ += 1;
    this->value_ = EuclidMod(this->value_, mod);
    return tmp;
  }
  ModInt& operator--() {
    value_ -= 1;
    value_ = EuclidMod(value_, mod);
    return *this;
  }
  ModInt operator--(int) {
    ModInt tmp = *this;
    this->value_ -= 1;
    this->value_ = EuclidMod(this->value_, mod);
    return tmp;
  }
  int64_t GetValue() const { return value_; }
};
template <int64_t mod>
ModInt<mod> operator+(const ModInt<mod>& left, const ModInt<mod>& right) {
  return ModInt<mod>(left) += right;
}
template <int64_t mod>
ModInt<mod> operator-(const ModInt<mod>& left, const ModInt<mod>& right) {
  return ModInt<mod>(left) -= right;
}
template <int64_t mod>
ModInt<mod> operator/(const ModInt<mod>& left, const ModInt<mod>& right) {
  return ModInt<mod>(left) /= right;
}
template <int64_t mod>
ModInt<mod> operator*(const ModInt<mod>& left, const ModInt<mod>& right) {
  return ModInt<mod>(left) *= right;
}
template <int64_t mod>
ModInt<mod> operator^(const ModInt<mod>& left, const ModInt<mod>& right) {
  return ModInt<mod>(left) ^= right;
}
template <int64_t mod>
std::ostream& operator<<(std::ostream& stream, const ModInt<mod>& mod_int) {
  stream << mod_int.GetValue();
  return stream;
}
int main() {
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  lint n;
  cin >> n;
  vector<Iwashi> iwashi(n);
  for (int i = 0; i < n; i++) {
    lint a, b;
    cin >> a >> b;
    iwashi[i] = Iwashi(a, b, i);
  }
  UnionFindForest uf(n);
  const int64_t MOD = 1000000007;
  ModInt<MOD> result(1);
  std::sort(iwashi.begin(), iwashi.end());
  for (int i = 0; i < n - 1; i++) {
    if (iwashi[i] == iwashi[i + 1]) {
      uf.Unite(iwashi[i].n, iwashi[i + 1].n);
    }
  }
  for (auto iw : iwashi) {
    Iwashi key(-iw.b, iw.a, iw.n);
    auto candidate = lower_bound(iwashi.begin(), iwashi.end(), key);
    if (*candidate == key) {
      uf.Unite(candidate->n, iw.n);
    }
  }
  unordered_set<lint> used_key;
  unordered_set<lint> root_key;
  unordered_map<lint, lint> pos_count, neg_count;
  for (auto iw : iwashi) {
    if (iw.n == uf.Root(iw.n)) {
      root_key.insert(iw.n);
    }
    if (iw.IsPositive()) {
      pos_count[uf.Root(iw.n)]++;
    } else {
      neg_count[uf.Root(iw.n)]++;
    }
  }
  for (auto rt : root_key) {
    ModInt<MOD> tmp(
        (neg_count[rt] == 0 ? 1 : RepeatedPowMod(2, neg_count[rt], MOD)));
    tmp += ModInt<MOD>(
        (pos_count[rt] == 0 ? 1 : RepeatedPowMod(2, pos_count[rt], MOD)));
    tmp--;
    result *= tmp;
  }
  cout << result - ModInt<MOD>(1) << endl;
  return 0;
}
