#include <bits/stdc++.h>
using namespace std;
long long n, a[200001], b[200001];
long long gcd(long long __A, long long __B) {
  return __A % __B ? gcd(__B, __A % __B) : __B;
}
struct Fraction {
  long long molecule, denominator;
  Fraction() { denominator = 1; }
  void read(long long a, long long b) {
    molecule = a;
    denominator = b;
    reduction();
  }
  void reduction() {
    if (molecule == 0) {
      denominator = 1;
      return;
    }
    long long GCD = gcd(molecule, denominator);
    molecule /= GCD;
    denominator /= GCD;
    if (denominator < 0) {
      molecule = -molecule;
      denominator = -denominator;
    }
  }
  friend void reduction_of_fractions_to_a_common_denominator(Fraction &a,
                                                             Fraction &b) {
    a.reduction();
    b.reduction();
    long long GCD = gcd(a.denominator, b.denominator);
    a.molecule *= b.denominator / GCD;
    b.molecule *= a.denominator / GCD;
    a.denominator = b.denominator = a.denominator * b.denominator / GCD;
  }
  Fraction operator-() const {
    Fraction tmp = *this;
    tmp.molecule = -tmp.molecule;
    return tmp;
  }
  Fraction reciprocal() const {
    Fraction tmp;
    tmp.molecule = denominator;
    tmp.denominator = molecule;
    tmp.reduction();
    return tmp;
  }
  Fraction operator+(const Fraction x) const {
    Fraction tmp, a = *this, b = x;
    reduction_of_fractions_to_a_common_denominator(a, b);
    tmp.molecule = a.molecule + b.molecule;
    tmp.denominator = a.denominator;
    tmp.reduction();
    return tmp;
  }
  Fraction operator-(const Fraction x) const { return *this + (-x); }
  Fraction operator*(const Fraction x) const {
    Fraction tmp;
    tmp.molecule = molecule * x.molecule;
    tmp.denominator = denominator * x.denominator;
    tmp.reduction();
    return tmp;
  }
  Fraction operator/(const Fraction x) const {
    return *this * (x.reciprocal());
  }
  bool operator==(const Fraction x) const {
    Fraction a = *this, b = x;
    reduction_of_fractions_to_a_common_denominator(a, b);
    if (a.molecule == b.molecule) {
      return true;
    }
    return false;
  }
  bool operator<(const Fraction x) const {
    Fraction a = *this, b = x;
    reduction_of_fractions_to_a_common_denominator(a, b);
    if (a.molecule < b.molecule) {
      return true;
    }
    return false;
  }
  bool operator>(const Fraction x) const {
    Fraction a = *this, b = x;
    reduction_of_fractions_to_a_common_denominator(a, b);
    if (a.molecule > b.molecule) {
      return true;
    }
    return false;
  }
  bool operator!=(const Fraction x) const {
    Fraction a = *this, b = x;
    reduction_of_fractions_to_a_common_denominator(a, b);
    if (a.molecule != b.molecule) {
      return true;
    }
    return false;
  }
  bool operator<=(const Fraction x) const {
    Fraction a = *this, b = x;
    reduction_of_fractions_to_a_common_denominator(a, b);
    if (a.molecule <= b.molecule) {
      return true;
    }
    return false;
  }
  bool operator>=(const Fraction x) const {
    Fraction a = *this, b = x;
    reduction_of_fractions_to_a_common_denominator(a, b);
    if (a.molecule >= b.molecule) {
      return true;
    }
    return false;
  }
  Fraction be(const long long x) {
    Fraction tmp;
    tmp.molecule = x;
    tmp.denominator = 1;
    return tmp;
  }
  Fraction be(const double x, const long long l) {
    Fraction tmp;
    tmp.denominator = 1;
    for (long long i = 1; i <= l; ++i) {
      tmp.denominator *= 10;
    }
    tmp.molecule = x * tmp.denominator;
    return tmp;
  }
} k[200001];
map<Fraction, long long> l;
long long cnt, s[200001], ans, t[200001], p[200001];
long long C(long long a, long long b) {
  return t[a] * p[b] % 1000000007 * p[a - b] % 1000000007;
}
long long pow(long long a, long long b, long long c) {
  long long tmp = 1;
  while (b) {
    if (b & 1) {
      tmp = (tmp * a) % c;
    }
    b >>= 1;
    a = (a * a) % c;
  }
  return tmp;
}
signed main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  t[0] = 1;
  p[0] = 1;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i];
    k[i].molecule = a[i];
    k[i].denominator = b[i];
    k[i].reduction();
    ++l[k[i]];
    t[i] = t[i - 1] * i % 1000000007;
    p[i] = pow(t[i], 1000000007 - 2, 1000000007);
  }
  for (long long i = 1; i <= n; ++i) {
    if (l[k[i]]) {
      Fraction tmp = -k[i].reciprocal();
      s[++cnt] = 1;
      for (long long j = 1; j <= l[k[i]]; ++j) {
        s[cnt] = (s[cnt] + C(l[k[i]], j)) % 1000000007;
      }
      for (long long j = 1; j <= l[tmp]; ++j) {
        s[cnt] = (s[cnt] + C(l[tmp], j)) % 1000000007;
      }
      l[k[i]] = l[tmp] = 0;
    }
  }
  ans = 1;
  for (long long i = 1; i <= cnt; ++i) {
    ans = (ans * s[i]) % 1000000007;
  }
  cout << (ans + 1000000007 - 1) % 1000000007 << endl;
  return 0;
}
