#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long calcproduct(int n) {
  long long ans = 1;
  for (int i = 1; i <= n; i++) {
    ans *= i;
    ans %= 1000000007;
  }
  return ans;
}
long long mod_pow(long long x, long long n) {
  if (n == 0) return 1;
  long long res = mod_pow(x * x % 1000000007, n / 2);
  if (n & 1) res = res * x % 1000000007;
  return res;
}
long long combination(int n, int k) {
  long long a = calcproduct(n);
  long long b = calcproduct(k);
  long long c = calcproduct(n - k);
  b = mod_pow(b, 1000000007 - 2);
  c = mod_pow(c, 1000000007 - 2);
  long long ans = ((a * b) % 1000000007 * c) % 1000000007;
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> B(N);
  for (int i = 0; i < (N); i++) {
    cin >> A[i] >> B[i];
  }
  vector<long long> v1(N);
  vector<long long> v2(N);
  for (int i = 0; i < (N); i++) {
    v1[i] = A[i] * mod_pow(B[i], 1000000007 - 2) % 1000000007;
    v2[i] = B[i] * mod_pow(A[i], 1000000007 - 2) % 1000000007;
  }
  map<long long, long long> m1;
  map<long long, long long> m2;
  for (int i = 0; i < (N); i++) {
    if (m1.count(-v2[i])) {
      m2[-v2[i]]++;
    } else
      m2[v1[i]]++;
    m1[v1[i]]++;
  }
  vector<int> v(N + 1, 0);
  for (auto ite = m2.begin(); ite != m2.end(); ite++) {
    v[ite->second]++;
  }
  long long ans = 1;
  for (int i = 1; i <= N; i++) {
    if (v[i] != 0) {
      for (int j = 0; j < (v[i]); j++) {
        ans *= i + 1;
        ans %= 1000000007;
      }
    }
  }
  if (ans == 0)
    cout << 1000000007 - 1 << endl;
  else
    cout << ans - 1 << endl;
}
