#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long ans;
  cin >> N;
  std::vector<long long> a(N), b(N), f(N);
  long long A, B;
  cin >> A >> B;
  a[0] = A;
  b[0] = B;
  f[0] = 0;
  ans = 0;
  for (int i = 1; i < N; i++) {
    cin >> A >> B;
    a[i] = A % 1000000007;
    b[i] = B % 1000000007;
    ans = 0;
    for (int j = 0; j < i; j++) {
      if (A / b[j] / a[j] * B != -1) {
        ans = ans + f[j] + 1;
      }
    }
    f[i] = ans % 1000000007;
  }
  cout << f[N - 1] + N;
}
