#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
void in() {}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
  cerr << " " << h;
  if (sizeof...(t) > 0) cerr << " :";
  debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
  for (size_t i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
ll ctoi(char c) {
  switch (c) {
    case '0':
      return 0;
    case '1':
      return 1;
    case '2':
      return 2;
    case '3':
      return 3;
    case '4':
      return 4;
    case '5':
      return 5;
    case '6':
      return 6;
    case '7':
      return 7;
    case '8':
      return 8;
    case '9':
      return 9;
    default:
      return 0;
  }
}
bool pairCompare(const pll firstElof, pll secondElof) {
  return firstElof.first > secondElof.first;
}
ll i, j, k, l;
ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007;
ll INF = 1LL << 60;
ll ans = 0;
ll z = 0, o = 1;
vl flag, D;
vll path;
vl Ans;
ll binarySearch(vl V, ll key) {
  ll left = -1;
  ll right = V.size();
  while (right - left > 1) {
    ll mid = left + (right - left) / 2;
    if (V[mid] >= key)
      right = mid;
    else
      left = mid;
  }
  return right;
}
ll Npow(ll x, ll n) {
  if (n == 0) return 1;
  if (n % 2 == 0)
    return Npow(x * x % MOD, n / 2);
  else
    return x * Npow(x, n - 1) % MOD;
}
map<ll, ll> primeFactorize(ll n, map<ll, ll>& PF) {
  while (n % 2 == 0) {
    PF[2]++;
    n /= 2;
  }
  for (ll p = 3; p * p <= n; p += 2) {
    while (n % p == 0) {
      PF[p]++;
      n /= p;
    }
  }
  if (n != 1) {
    PF[n]++;
  }
  return PF;
}
int main() {
  cin >> N;
  vl A(N), B(N);
  ll Az = 0, Bz = 0, allz = 0;
  vpll P, Q;
  for (i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
    if (A[i] == 0 && B[i] == 0)
      allz++;
    else if (A[i] == 0)
      Az++;
    else if (B[i] == 0)
      Bz++;
    else if (A[i] > 0 && B[i] > 0) {
      P.push_back(make_pair(A[i], B[i]));
    } else if (A[i] > 0 && B[i] < 0) {
      Q.push_back(make_pair(A[i], -B[i]));
    } else if (A[i] < 0 && B[i] > 0) {
      Q.push_back(make_pair(-A[i], B[i]));
    } else if (A[i] < 0 && B[i] < 0) {
      P.push_back(make_pair(-A[i], -B[i]));
    }
  }
  ans = Npow(2, N) - 1;
  ll Z = Az * Bz + Az * allz + Bz * allz;
  ans = ((ans - (Z * Npow(2, N - 2)) % MOD + MOD) % MOD + MOD) % MOD;
  map<map<ll, ll>, ll> Ans1;
  map<map<ll, ll>, ll> Ans2;
  for (i = 0; i < P.size(); i++) {
    map<ll, ll> Pa, Pb, Pc;
    primeFactorize(P[i].first, Pa);
    primeFactorize(P[i].second, Pb);
    Pc = Pb;
    for (auto x : Pa) {
      Pc[x.first] -= x.second;
    }
    Ans1[Pc]++;
  }
  for (i = 0; i < Q.size(); i++) {
    map<ll, ll> Qa, Qb, Qc;
    primeFactorize(Q[i].first, Qa);
    primeFactorize(Q[i].second, Qb);
    Qc = Qa;
    for (auto x : Qb) {
      Qc[x.first] -= x.second;
    }
    Ans2[Qc]++;
  }
  ll ans = 1;
  ll pre2 = N;
  for (auto x : Ans1) {
    ll pre = x.second * Ans2[x.first];
    ll a = x.second;
    ll b = Ans2[x.first];
    if (a > 0 && b > 0) {
      ans =
          (ans * (Npow(2, a + b) - (Npow(2, a) - 1) * (Npow(2, b) - 1)) % MOD) %
          MOD;
      pre2 -= a + b;
    }
  }
  (ans *= Npow(2, pre2)) %= MOD;
  ans--;
  cout << ans;
}
