#include <bits/stdc++.h>
using namespace std;
template <class T>
void print(const T& x) {
  cout << x << endl;
}
template <class T, class... A>
void print(const T& first, const A&... rest) {
  cout << first << " ";
  print(rest...);
}
struct PreMain {
  PreMain() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} premain;
const int mod = 1e9 + 7;
struct mint {
  long long x;
  mint(long long a = 0) { x = a >= 0 ? a % mod : mod - (-a) % mod; }
  mint(const mint& m) : x(m.x) {}
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator+=(const int& a) {
    if ((x += a) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const int& a) {
    if ((x += mod - a) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint& operator*=(const int& a) {
    (x *= a) %= mod;
    return *this;
  }
  mint operator+(const mint& a) const {
    mint res(*this);
    return res += a;
  }
  mint operator+(const int& a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint& a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator-(const int& a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator-() const {
    mint res(*this);
    return mint(0) - res;
  }
  mint operator*(const mint& a) const {
    mint res(*this);
    return res *= a;
  }
  mint operator*(const int& a) const {
    mint res(*this);
    return res *= a;
  }
  bool operator==(const mint& a) const { return x == a.x; }
  bool operator==(const int& a) const { return x == a; }
  bool operator!=(const mint& a) const { return x != a.x; }
  bool operator!=(const int& a) const { return x != a; }
  operator bool() const { return x > 0; }
  mint pow(long long t) const {
    mint r = 1, a = *this;
    do {
      if (t & 1) r *= a;
      a *= a;
    } while (t >>= 1);
    return r;
  }
  mint pow(mint t) const {
    mint r = 1, a = *this;
    do {
      if (t.x & 1) r *= a;
      a *= a;
    } while (t.x >>= 1);
    return r;
  }
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint& a) { return (*this) *= a.inv(); }
  mint& operator/=(const int& a) { return (*this) *= mint(a).inv(); }
  mint operator/(const mint& a) const {
    mint res(*this);
    return res /= a;
  }
  mint operator/(const int& a) const {
    mint res(*this);
    return res /= a;
  }
  friend ostream& operator<<(ostream& os, const mint& m) {
    cout << m.x;
    return os;
  }
  friend istream& operator>>(istream& is, mint& m) { return is >> m.x; }
};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  int N;
  cin >> N;
  vector<long long> A(N), B(N);
  for (int(i) = 0; (i) < (int)(N); ++(i)) {
    cin >> A[i] >> B[i];
    long long d = gcd(abs(A[i]), abs(B[i]));
    A[i] /= d;
    B[i] /= d;
    if (A[i] <= 0 && B[i] >= 0) {
      A[i] *= -1;
      B[i] *= -1;
    }
    if (A[i] <= 0 && B[i] <= 0) {
      A[i] *= -1;
      B[i] *= -1;
    }
  }
  mint ans = 1;
  ans -= mint(1);
  print(ans);
  return 0;
}
