#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
vector<int> A, B;
map<long long, long long> prime_factor(long long N) {
  map<long long, long long> res;
  for (long long i = 2; i * i <= N; i++) {
    while (N % i == 0) {
      ++res[i];
      N /= i;
    }
  }
  if (N != 1) res[N] = 1;
  return res;
}
long long mod_pow(long long x, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
int main() {
  int N;
  cin >> N;
  A = vector<int>(N);
  B = vector<int>(N);
  map<pair<int, int>, long long> cnt;
  for (int i = (0); i < (N); i++) {
    cin >> A[i] >> B[i];
    map<long long, long long> resA = prime_factor(abs(A[i]));
    map<long long, long long> resB = prime_factor(abs(B[i]));
    for (auto itr : resA) {
      long long div = itr.first, cntA = itr.second;
      long long same = min(cntA, resB[div]);
      A[i] /= mod_pow(div, same, MOD);
      B[i] /= mod_pow(div, same, MOD);
    }
    cnt[pair<int, int>(A[i], B[i])]++;
  }
  long long ans = 0;
  for (int i = (0); i < (N); i++) {
    long long ct = N - 1 - i;
    ct -= cnt[pair<int, int>(B[i], -A[i])];
    ct -= cnt[pair<int, int>(-B[i], A[i])];
    ans += mod_pow(2, ct, MOD);
    ans %= MOD;
    cnt[pair<int, int>(A[i], B[i])]--;
  }
  cout << ans << endl;
  return 0;
}
