import math

#print(math.cos(math.radians(90)))

#exit()

x = int(eval(input()))

print((360//math.gcd(360,x)))
x = int(eval(input()))

for i in range(1000):

    if x * (i+1) % 360 == 0:

        print((i+1))

        exit()

import math

# print(math.cos(math.radians(90)))
# exit()
x = int(eval(input()))
print((360 // math.gcd(360, x)))

x = int(eval(input()))
for i in range(1000):
    if x * (i + 1) % 360 == 0:
        print((i + 1))
        exit()

-import math - -# print(math.cos(math.radians(90))) -# exit() -print((360 // math.gcd(360, x))) +for i in range(1000): +    if x * (i + 1) % 360 == 0: +        print((i + 1)) +        exit()