#include <bits/stdc++.h>
using namespace std;
long long int inf = 1e18;
long long int p = 1e9 + 7;
long long int phi(long long int n) {
  long long int result = n;
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      result -= result / i;
    }
  }
  if (n > 1) result -= result / n;
  return result;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int modInverse(long long int n, long long int p) {
  return power(n, p - 2, p);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, j, x, y, k, t, n, z, c, d, r, m;
  long double t1, t2, t3, t4;
  cin >> n;
  map<long double, long long int> ma;
  for (i = 0; i < n; i++) {
    cin >> t1 >> t2;
    long double t3 = t1 / t2;
    ma[t3]++;
  }
  long long int ans = 1;
  for (auto u : ma) {
    t1 = u.first;
    x = ma[t1];
    t2 = (1.0 / t1);
    t2 *= (-1.0);
    y = ma[t2];
    if (x > 0 || y > 0) {
      c = power(2, x, p);
      d = power(2, y, p);
      c--;
      d--;
      c = (c + p) % p;
      d = (d + p) % p;
      long long int e = (c * d) % p;
      long long int f = power(2, x + y, p);
      f -= e;
      f = (f + p) % p;
      ans *= f;
      ans %= p;
    }
    ma[t1] = 0;
    ma[t2] = 0;
  }
  ans = (ans + p - 1) % p;
  cout << ans;
  return 0;
}
