#include <bits/stdc++.h>
using u64 = unsigned long long int;
using s64 = long long int;
using u32 = unsigned int;
constexpr u32 mod = 1000000007;
int n;
u32 pow2[200001];
void reduce(u64 *a, u64 *b) {
  u64 s, t, u, v;
  s = v = 1;
  u = t = 0;
  while (*a) {
    u64 q = *b / *a;
    u64 r = *b % *a;
    std::tie(s, t, u, v) = std::forward_as_tuple(u, v, s + q * u, t + q * v);
    *b = *a;
    *a = r;
  }
  *a = u;
  *b = v;
}
u64 hash(u64 a, u64 b) {
  const u64 x = 7;
  const u64 p = (1ULL << 61) - 1;
  return (a * x + b) % p;
}
int main() {
  scanf("%d", &n);
  pow2[0] = 1;
  for (int i = 1; i <= n; i++) {
    pow2[i] = 2 * pow2[i - 1];
    if (pow2[i] >= mod) pow2[i] -= mod;
  }
  using quot = u64;
  std::vector<quot> vp, vn;
  u32 zeroa = 0;
  u32 zerob = 0;
  u32 zero2 = 0;
  for (int i = 0; i < n; i++) {
    s64 a, b;
    scanf("%lld%lld", &a, &b);
    if (a == 0 && b == 0)
      zero2++;
    else if (a == 0)
      zeroa++;
    else if (b == 0)
      zerob++;
    else if ((a ^ b) >= 0) {
      u64 ua = std::abs(a);
      u64 ub = std::abs(b);
      reduce(&ua, &ub);
      vp.push_back(hash(ua, ub));
    } else {
      u64 ua = std::abs(a);
      u64 ub = std::abs(b);
      reduce(&ua, &ub);
      vn.push_back(hash(ub, ua));
    }
  }
  std::sort(vp.begin(), vp.end());
  std::sort(vn.begin(), vn.end());
  std::vector<std::pair<quot, u32> > vpp, vnn;
  quot prev = -1;
  for (auto const &x : vp) {
    if (x == prev)
      vpp.back().second++;
    else {
      vpp.emplace_back(x, 1);
      prev = x;
    }
  }
  prev = -1;
  for (auto const &x : vn) {
    if (x == prev)
      vnn.back().second++;
    else {
      vnn.emplace_back(x, 1);
      prev = x;
    }
  }
  u64 ans = (pow2[zeroa] + pow2[zerob] + mod - 1) % mod;
  auto ip = vpp.begin(), in = vnn.begin();
  while (ip != vpp.end() && in != vnn.end()) {
    if (ip->first == in->first) {
      ans = ans * (pow2[ip->second] + pow2[in->second] + mod - 1) % mod;
      ++ip, ++in;
    } else if (ip->first < in->first) {
      ans = ans * pow2[ip->second] % mod;
      ++ip;
    } else {
      ans = ans * pow2[in->second] % mod;
      ++in;
    }
  }
  while (in != vnn.end()) {
    ans = ans * pow2[in->second] % mod;
    ++in;
  }
  while (ip != vpp.end()) {
    ans = ans * pow2[ip->second] % mod;
    ++ip;
  }
  ans = (ans + zero2 + mod - 1) % mod;
  printf("%llu\n", ans);
  return 0;
}
