#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1e18;
long long pow(long long x, long long n) {
  long long ret = 1;
  while (n > 0) {
    if (n & 1) ret = ret * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return ret;
}
template <typename T, typename U>
bool chmax(T& max, const U& x) {
  if (max < x) {
    max = x;
    return true;
  }
  return false;
}
template <typename T, typename U>
bool chmin(T& min, const U& x) {
  if (min > x) {
    min = x;
    return true;
  }
  return false;
}
int main() {
  long long n;
  vector<pair<double, long long>> ab;
  vector<long long> chokkou;
  cin >> n;
  for (long long j = 0; j < n; j++) {
    long long a, b;
    cin >> a >> b;
    bool f = true;
    long long now;
    for (long long i = 0; i < ab.size(); i++) {
      if (abs(ab[i].first - b / a) < 0.00000000000001) {
        ab[i].second++;
        f = false;
        now = i;
      }
    }
    if (f) {
      ab.push_back(make_pair(b / a, 1));
      chokkou.push_back(-1);
      now = chokkou.size();
    }
    for (long long i = 0; i < ab.size(); i++) {
      if (ab[i].first / a * b + 1 < 0.00000000000001) {
        chokkou[now] = i;
      }
    }
  }
  long long ans = 0;
  long long base = 0;
  vector<long long> niku;
  for (long long i = 0; i < ab.size(); i++) {
    if (chokkou[i] == -1) {
      base += ab[i].second;
    } else {
      niku.push_back(pow(2, ab[i].second) * pow(2, ab[chokkou[i]].second) - 1);
      chokkou[chokkou[i]] = -1;
      cout << endl;
    }
  }
  ans = pow(2, base);
  for (auto& e : niku) {
    ans = ans * e % MOD;
  }
  cout << ans - 1 << endl;
}
