from math import gcd
with open("ulamki.txt", "r") as file:
fractions = [list(map(int, str.split(" "))) for str in file.read().split("\n")]
with open("skrocone.txt", "w") as out_file:
for fraction in fractions:
divisor = gcd(fraction[0], fraction[1])
fraction[0] //= divisor
fraction[1] //= divisor
print(f"{fraction[0]} {fraction[1]}", file=out_file)