• + 0 comments

    from math import gcd

    def simplify(nomerator, demirator): common_diviser = gcd(nomerator, demirator) return nomerator // common_diviser, demirator // common_diviser

    def product_of_relations(relations): nomerator = 1 demirator = 1 for num, den in relations: nomerator *= num demirator *= den

    return simplify(nomerator, demirator)
    

    n = int(input()) relations = [tuple(map(int, input().split())) for _ in range(n)] result_nomerator, result_denominator = product_of_relations(relations) print(result_nomerator, result_denominator)