#include <bits/stdc++.h>
constexpr double INFI = 1.0E18 + 1;
constexpr int BASE = 1000000007;
using namespace std;
int modpow(int a, int b, int base) {
  vector<int> vb, va;
  while (b != 0) {
    vb.push_back(b % 2);
    b /= 2;
    va.push_back(a);
    a *= a;
    a %= base;
  }
  int ans = 1;
  for (int i = 0; i < vb.size(); i++) {
    if (vb[i] == 1) {
      ans *= va[i];
      ans %= base;
    }
  }
  return ans;
}
int main() {
  int n;
  vector<double> v;
  double a, b;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a == 0) {
      v.push_back(1ll / INFI);
    } else if (b == 0) {
      v.push_back(INFI);
    } else {
      v.push_back(a / b);
    }
  }
  sort(v.begin(), v.end());
  vector<pair<double, int>> v2;
  v2.push_back(make_pair(v[0], 1));
  double now = v[0];
  for (int i = 1; i < n; i++) {
    if (v[i] == now) {
      v2[v2.size() - 1].second++;
    } else {
      v2.push_back(make_pair(v[i], 1));
    }
  }
  vector<double> v3;
  vector<long long> v4;
  long long sum = 0;
  for (int i = 0; i < v2.size(); i++) {
    v3.push_back(v2[i].first);
    if (v2[i].first <= 1 / INFI) {
      v4.push_back((1 + sum) % BASE);
      v4[i] *= modpow(2, v2[i].second, BASE);
      v4[i] %= BASE;
      sum += v4[i];
      sum %= BASE;
    } else {
      if (binary_search(v4.begin(), v4.end(), 1 / v2[i].first)) {
        v4.push_back(
            (1LL + sum +
             (BASE - v4[lower_bound(v4.begin(), v4.end(), 1 / v2[i].first) -
                        v4.begin()])) %
            BASE);
        v4[i] *= modpow(2, v2[i].second, BASE);
        v4[i] %= BASE;
        sum += v4[i];
        sum %= BASE;
      } else {
        v4.push_back((1 + sum) % BASE);
        v4[i] *= modpow(2, v2[i].second, BASE);
        v4[i] %= BASE;
        sum += v4[i];
        sum %= BASE;
      }
    }
  }
  sum = 0;
  for (int i = 0; i < v4.size(); i++) {
    sum += v4[i];
    sum %= BASE;
  }
  cout << sum << endl;
}
