#include <stdio.h>

typedef long long ll;

ll dfs(int i, int n, ll count, double c[]) {
  if(i == n) {
    return count + 1;
  }
  ll 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;
  ll a[200001] = {0};
  ll b[200001] = {0};
  double c[200001] = {0};
  scanf("%d", &n);
  for(int i = 0;i < n;i++) {
    scanf("%lld %lld", a + i, b + i);
    c[i] = (double)a / b;
  }
  ll ret = n;
  ret += dfs(2, n, ret, c);
  
  printf("%lld\n", ret % (1000000007));
  return 0;
}
  	  
