#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
namespace {
template <typename T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
template <typename T>
void Cout(const T& x, const char* end = "\n") {
  std::cout << x << end;
}
template <typename T>
void Cout(const std::vector<T>& x, const char* sep = " ",
          const char* end = "\n") {
  for (std::size_t i = 0, sz = x.size(); i < sz; ++i) {
    std::cout << x[i] << (i == sz - 1 ? end : sep);
  }
}
struct inp {
  std::size_t szi, szj;
  inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
  template <typename T>
  operator T() const {
    T a;
    std::cin >> a;
    return a;
  }
  template <typename T>
  operator std::vector<T>() const {
    std::vector<T> a(szi);
    for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i];
    return a;
  }
  template <typename T>
  operator std::vector<std::vector<T>>() const {
    std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
    for (std::size_t i = 0; i < szi; ++i)
      for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j];
    return a;
  }
};
inp inp1;
ll modpow(ll a, ll n) {
  ll result = 1;
  ll base = a;
  ll mask = 1;
  while (mask <= n) {
    if (n & mask) (result *= base) %= mod;
    mask <<= 1;
    (base *= base) %= mod;
  }
  return result;
}
template <typename T>
std::vector<T> Factorize2Vector(T x) {
  if (x <= 1) return std::vector<T>();
  std::vector<T> r;
  T x0 = x;
  while (x % 2 == 0) x /= 2, r.push_back(2);
  for (long long f = 3; f * f <= x0; f += 2)
    while (x % f == 0) x /= f, r.push_back(f);
  if (x > 1) r.push_back(x);
  return r;
}
}  // namespace
int main() {
  int n = inp1;
  vector<ll> a(n), b(n);
  for (ll i = 0; i < n; ++i) cin >> a[i] >> b[i];
  for (ll i = 0; i < n; ++i) {
    ll ta = abs(a[i]);
    ll tb = abs(b[i]);
    auto facts = Factorize2Vector(tb);
    for (auto v : facts) {
      if (ta % v == 0) {
        ta /= v;
        tb /= v;
      }
    }
    a[i] = a[i] / abs(a[i]) * ta;
    b[i] = b[i] / abs(b[i]) * tb;
  }
  for (ll i = 0; i < n; ++i) cout << a[i] << " " << b[i] << endl;
  map<pair<ll, ll>, ll> mp;
  ll ans = 0LL;
  ll out_num = 0LL;
  for (ll i = 0; i < n; ++i) {
    ll out = mp[{a[i], b[i]}];
    ll select = i + 1 - out;
    ll add = 0LL;
    add += modpow(2, select - 2);
    ll tmp = modpow(2, i + 1) - add;
    add = add + 1 - out_num;
    out_num = tmp;
    ans %= mod;
    ++mp[{-b[i], a[i]}];
    ++mp[{b[i], -a[i]}];
  }
  Cout(ans);
  return 0;
}
