#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  for (int i = 0; i < ((int)vec.size()); i++) os << (i ? ", " : "") << vec[i];
  os << "]";
  return os;
}
template <typename T>
istream& operator>>(istream& is, pair<T, T>& p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T, T>& p) {
  os << p.first << " " << p.second;
  return os;
}
template <typename T>
bool operator<(vector<T>& a, vector<T>& b) {
  for (int i = 0; i < ((int)a.size()); i++) {
    if (i == b.size()) return false;
    if (a[i] < b[i])
      return true;
    else if (a[i] > b[i])
      return false;
  }
  return false;
}
template <typename T>
bool operator>(vector<T>& a, vector<T>& b) {
  for (int i = 0; i < ((int)a.size()); i++) {
    if (i == b.size()) return true;
    if (a[i] < b[i])
      return false;
    else if (a[i] > b[i])
      return true;
  }
  return false;
}
int bitcnt(long long x) {
  x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
  x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
  x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
  x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
  x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
  x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
  return x;
}
int bitcnt(int x) {
  x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
  x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
  x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
  x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
  x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
  return x;
}
long long sqrtll(long long x) {
  long long left = 0, right = x;
  for (int i = 0; i < ((int)100); i++) {
    long long mid = (left + right) >> 1;
    if (mid * mid <= x)
      left = mid;
    else
      right = mid;
  }
  return left;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const long double infl = 1e100;
const long long mod = 1e9 + 7;
const long double eps = 1e-9;
const long long inf = 1e15;
const int dx[] = {1, 0, -1, 0, 0};
const int dy[] = {0, 1, 0, -1, 0};
long long pow2[200010];
int main() {
  int n;
  cin >> n;
  pow2[0] = 1;
  for (int i = 1; i <= ((int)n); i++) {
    pow2[i] = (pow2[i - 1] * 2) % mod;
  }
  vector<pair<long long, long long> > d;
  multiset<pair<long long, long long> > m;
  for (int i = 0; i < ((int)n); i++) {
    long long a, b;
    cin >> a >> b;
    long long g = gcd(a, b);
    a /= g;
    b /= g;
    d.push_back(make_pair(a, b));
    m.insert(make_pair(a, b));
  }
  long long res = 1;
  cout << (res + mod - 1) % mod << endl;
  return 0;
}
