#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
long long INF = 4001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}
using Graph = vector<vector<long long>>;
vector<long long> P;
void Primefactor(long long n) {
  long long a = n;
  for (long long i = 2; i * i <= n; i++) {
    while (a % i == 0) {
      P.push_back(i);
      a /= i;
    }
    if (a == 1) {
      break;
    }
  }
  if (a != 1) {
    P.push_back(a);
  }
  return;
}
long long sing(long long a, long long b) {
  if ((a > 0 && b > 0) || (a < 0 && b < 0)) return 1;
  if ((a > 0 && b < 0) || (a < 0 && b > 0)) return 2;
  if (a == 0 || b == 0) return 3;
  return -1;
}
long long A[200010];
long long B[200010];
long long tableF[200010];
long long tableI[200010];
long long modfact(long long a, long long m) {
  if (tableF[a] != -1) {
    return tableF[a];
  }
  if (a == 1) {
    tableF[a] = 1;
    return tableF[a];
  }
  long long res = 1;
  res = a * modfact(a - 1, m);
  res %= m;
  tableF[a] = res;
  return res;
}
long long modpow(long long a, long long n, long long m) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}
long long modinv(long long a, long long p) {
  long long res = modpow(a, p - 2, p);
  return res;
}
long long modCON(long long n, long long r, long long m) {
  if (n < 200010) {
    long long res = 1;
    if (n < 0 || r < 0 || n < r) {
      return 0;
    }
    res *= tableF[n];
    res %= m;
    res *= tableI[r];
    res %= m;
    res *= tableI[n - r];
    res %= m;
    return res;
  } else {
    long long res = 1;
    for (int i = 1; i <= n; i++) {
      res *= i;
      res %= m;
    }
    for (int i = 1; i <= r; i++) {
      res *= modinv(i, m);
      res %= m;
    }
    for (int i = 1; i <= n - r; i++) {
      res *= modinv(i, m);
      res %= m;
    }
    return res;
  }
}
void modfill(long long m) {
  fill(tableF, tableF + 200010, -1);
  fill(tableI, tableI + 200010, -1);
  tableF[0] = 1;
  tableI[0] = 1;
  for (int i = 1; i < 200010; i++) {
    tableF[i] = modfact(i, m);
    tableI[i] = modinv(tableF[i], m);
  }
}
int main() {
  modfill(MOD);
  long long N;
  cin >> N;
  long long x = 0;
  map<pair<long long, map<long long, long long>>, long long> mp;
  for (long long i = (long long)0; i < (long long)N; i++) {
    P = vector<long long>();
    long long a, b;
    cin >> a >> b;
    pair<long long, map<long long, long long>> p, q;
    p.first = sing(a, b);
    Primefactor(abs(a));
    Primefactor(abs(b));
    for (long long j = (long long)0; j < (long long)P.size(); j++)
      p.second[P[j]]++;
    q = p;
    if (sing(a, b) == 1) {
      q.first = 2;
    }
    if (sing(a, b) == 2) {
      q.first = 1;
    }
    x += mp[q];
    mp[p]++;
  }
  long long ans = modpow(2, N, MOD) - 1 - N;
  for (long long i = (long long)1; i < (long long)x + 1; i++) {
    if (i % 2 == 0)
      ans += modCON(x, i, MOD);
    else
      ans -= modCON(x, i, MOD);
    while (ans < 0) ans += MOD * 100000000;
    ans %= MOD;
  }
  cout << ans << endl;
}
