#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
long long mpow(long long m, long long p) {
  long long power = m;
  long long res = 1;
  while (p > 0) {
    if (p & 1) res = res * power % MOD;
    power = (power * power) % MOD;
    p /= 2;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> a(n), b(n);
  for (int i = 0; i < ((int)n); i++) cin >> a[i] >> b[i];
  map<long double, long long> m;
  vector<long double> x;
  for (int i = 0; i < ((int)n); i++) {
    long double t = a[i] * 1.0 / b[i];
    m[t] += 1;
    x.push_back(t);
  }
  (sort(x.begin(), x.end()),
   x.resize(distance(x.begin(), unique(x.begin(), x.end()))));
  long long ans = 1;
  long long k = x.size();
  vector<bool> visited_x(k, false);
  for (int i = 0; i < ((int)k); i++) {
    if (visited_x[i]) continue;
    long long q = mpow(2, m[x[i]]);
    long long w = 0;
    visited_x[i] = true;
    auto it = lower_bound(x.begin(), x.end(), -1.0 / x[i]);
    if (it != x.end()) {
      if (*it == -1.0 / x[i]) {
        long long index = it - x.begin();
        visited_x[index] = true;
        w = mpow(2, m[*it]) - 1;
      }
    }
    ans = ans * (q + w) % MOD;
  }
  cout << ans - 1 << endl;
}
