#include <bits/stdc++.h>
constexpr char bn = '\n';
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
const ll tl = 1000000007;
void in() {}
template <typename T, class... U>
void in(T &t, U &...u) {
  cin >> t;
  in(u...);
}
void out() { cout << endl; }
template <typename T, class... U>
void out(const T &t, const U &...u) {
  cout << t;
  if (sizeof...(u)) cout << " ";
  out(u...);
}
template <typename T>
void die(T x) {
  out(x);
  exit(0);
}
struct Point {
  ld x, y;
};
ld dist(Point a, Point b) {
  return sqrt(abs(a.x - b.x) * abs(a.x - b.x) +
              abs(a.y - b.y) * abs(a.y - b.y));
}
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll fact(ll n) {
  if (n < 2) return 1;
  return (n * fact(n - 1)) % tl;
}
inline ll updiv(ll a, ll b) { return (a + b - 1) / b; }
template <typename T, typename U>
ll ceil(T a, U b) {
  return (a + b - 1) / b;
}
template <class A, class B>
inline bool chmax(A &a, const B &b) {
  return b > a && (a = b, true);
}
template <class A, class B>
inline bool chmin(A &a, const B &b) {
  return b < a && (a = b, true);
}
int main() {
  init();
  ll ans = 0;
  long long n;
  in(n);
  vd A(n), B(n);
  map<ld, ll> T;
  for (ll i = 0; i < n; i++) {
    long long a, b;
    in(a, b);
    A[i] = 1;
    B[i] = b / a;
    T[B[i]]++;
  }
  ans = modpow(2, n, tl);
  ll k = modpow(2, n - 2, tl);
  ll m = 0;
  map<ld, ll> check;
  for (auto &x : T) {
    ld f = x.first;
    if (T[-f] != 0 && !check[-f]) {
      check[-f] = 1;
      m += fact(n - (T[f] + T[-f] - 1) % tl);
      m %= tl;
    }
  }
  out(ans - m);
}
