require 'pp'

# f = Fcational.new(max, MOD)
# f.at(10) #=> 10! (mod MOD)
# f.inv(10) #=> (10!)^(-1) (mod MOD)

class Fractional
    attr_reader :mod

    def initialize(max, mod)
        @max = max
        @mod = mod
        @frac     = { 0 => 1, 1 => 1 }
        @frac_inv = { 0 => 1, 1 => 1 }
        @inv      = {         1 => 1 }

        pre_calc(max)
    end

    def pre_calc(max)
        2.upto(max) do |i|
            @frac[i] = @frac[i - 1] * i % @mod;
            @inv[i] = @mod - @inv[@mod % i] * (@mod / i) % @mod
            @frac_inv[i] = @frac_inv[i - 1] * @inv[i] % @mod
        end
    end

    def at(i)
        @frac[i]
    end

    def inv_at(i)
        @frac_inv[i]
    end
end

# precalc_fraciotnalを使う前提
# f = Fcational.new(max, mod)
# c = Combination.new(f)
# c.calc(n, r)

class Combination
    def initialize(fraction)
        @fraction = fraction
    end

    def calc(n, r)
        return 0 if n < r
        return 0 if (n < 0 || r < 0)

        denom_inv = (@fraction.inv_at(r) * @fraction.inv_at(n - r) % @fraction.mod)
        return @fraction.at(n) * denom_inv % @fraction.mod
    end
end



# n^r (mod M)
def pow(n, r, m)
    ans = 1
    i = r
    x = n
    while i > 0
        if i % 2 == 0
            i /= 2
            x = (x ** 2) % m
        else
            i -= 1
            ans = (ans * x) % m
        end
    end

    return ans
end

#puts pow(2, 10**9,10 ** 9 + 7)

MOD = 1000000007
n = gets.to_i
x_n = Array.new(n)
memo1 = Array.new(n) # Aj / Bj
memo2 = Array.new(n) # -Bi / Ai
memo3 = Hash.new(0)
memo4 = Hash.new(0)
n.times do |i|
    a, b = gets.split.map(&:to_i)
    x_n[i] = [a, b]
    memo1[i] = Rational(a, 1) / Rational(b, 1)
    memo2[i] = Rational(-b, 1) / Rational(a, 1)

    memo3[memo1[i].to_s] += 1
    memo4[memo2[i].to_s] += 1
end

f = Fractional.new(2 * (10 ** 5), MOD)
c = Combination.new(f)
#.calc(n, r)

# 2組でかぶる組み合わせの合計
dup_comb = 0
memo3.each do |k, v|
    next if memo4[k].nil?

    dup_comb += v * memo4[k]
end
dup_comb /= 2

# nC0は入らない
sum = n # nC1

2.upto(n-dup_comb) do |r|
    sum += (((sum + c.calc(n-dup_comb, r)) % MOD) * dup_comb) % MOD
end    
puts sum
