X = int(eval(input()))

import math

A = X // math.gcd(360, X)

ans = 360 * A // X

print(ans)
X = int(eval(input()))

import math

ans = 360 // math.gcd(360, X)

print(ans)
X = int(eval(input()))
import math

A = X // math.gcd(360, X)
ans = 360 * A // X
print(ans)

X = int(eval(input()))
import math

ans = 360 // math.gcd(360, X)
print(ans)

-A = X // math.gcd(360, X) -ans = 360 * A // X +ans = 360 // math.gcd(360, X)