#include <bits/stdc++.h>
long long dfs(int i, int n, long long count, double c[]) {
  if (i == n) {
    return count + 1;
  }
  long long ret = 0;
  for (int j = i + 1; j <= n; j++) {
    if (c[i] + 1 / c[j] != 0) {
      ret += dfs(j, n, count + 1, c);
    }
  }
  return ret;
}
int main(void) {
  int n;
  long long a[200001] = {0};
  long long b[200001] = {0};
  double c[200001] = {0};
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld %lld", a + i, b + i);
    c[i] = (double)a[i] / b[i];
  }
  long long ret = n;
  ret += dfs(2, n, ret, c);
  printf("%lld\n", ret % (1000000007));
  return 0;
}
