#include <bits/stdc++.h>
using namespace std;
using vi = vector<long long>;
using pii = pair<long long, long long>;
using vpii = vector<pii>;
using ll = long long;
constexpr long long TEN(long long n) { return n == 0 ? 1 : 10 * TEN(n - 1); }
bool chmin(long long& a, long long b) { return a > b ? (a = b, true) : false; }
bool chmax(long long& a, long long b) { return a < b ? (a = b, true) : false; }
long long read() {
  long long a;
  scanf("%lld", &a);
  return a;
}
const long long mod = TEN(9) + 7;
ll inv[200010];
ll fac[200010], fac_inv[200010];
ll C(long long n, long long k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return ((fac[n] * fac_inv[k] % mod) * fac_inv[n - k]) % mod;
}
void comb_init() {
  long long N = 200005;
  inv[1] = 1;
  for (long long i = 2; i <= N; ++i) {
    inv[i] = mod - (mod / i) * inv[mod % i] % mod;
  }
  fac[0] = fac_inv[0] = 1;
  for (long long i = 1; i <= N; ++i) {
    fac[i] = (fac[i - 1] * i) % mod;
    fac_inv[i] = (fac_inv[i - 1] * inv[i]) % mod;
  }
}
inline ll mod_pow(ll a, ll x, ll m) {
  if (x == 0) return 1;
  ll res = mod_pow(a, x / 2, m);
  res *= res;
  res %= m;
  if (x % 2) {
    res *= a;
    res %= m;
  }
  return res;
}
long long N;
long long A[200010];
long long B[200010];
map<long double, long long> m;
map<long double, bool> used;
vpii data1;
long long dp[200010][3];
long long gcd(long long a, long long b) {
  if (a < 0) a = -a;
  if (b < 0) b = -b;
  return b == 0 ? a : gcd(b, a % b);
}
signed main() {
  cin >> N;
  long long cnt = 0;
  for (long long i = 0; i < (long long)(N); ++i) {
    cin >> A[i] >> B[i];
    if (A[i] == 0 or B[i] == 0) {
      cnt++;
      continue;
    }
    long long g = gcd(A[i], B[i]);
    A[i] /= g;
    B[i] /= g;
    m[(long double)A[i] / (long double)B[i]]++;
  }
  for (auto a : m) {
    if (used[a.first]) continue;
    data1.emplace_back(m[a.first], m[(long double)-1.0 / a.first]);
    used[a.first] = used[(long double)-1.0 / a.first] = true;
  }
  long long n = data1.size();
  dp[0][0] = 1;
  for (long long i = 0; i < n; ++i) {
    dp[i + 1][0] = (dp[i][0] + dp[i][1] + dp[i][2]) % mod;
    dp[i + 1][1] = (dp[i][0] + dp[i][1] + dp[i][2]) *
                   (mod_pow(2, data1[i].first, mod) - 1 + mod) % mod;
    dp[i + 1][2] = (dp[i][0] + dp[i][1] + dp[i][2]) *
                   (mod_pow(2, data1[i].second, mod) - 1 + mod) % mod;
  }
  long long ans = (dp[n][0] + dp[n][1] + dp[n][2]) * (cnt + 1) % mod - 1;
  if (ans < 0) ans += mod;
  cout << ans << endl;
}
