URI Online Judge | 2238


By Maratona de Programação da SBC – 2016 BR Brazil

Timelimit: 1

Think a positive number n. Now tell me an A divisor of n. Now give me another B number than n divider. Now a multiple C. and a non multiple D. The number you thought is ...

It looks like a magic trick, but math! Does knowing the numbers A, B, C and D, you can discover what the original number n? Note that there may be more than one solution!

This problem, given the values of A, B, C and D, you should write a program that determines which the smallest number n that may have been thought or conclude that there is no possible value.


The input consists of a single row containing four integers A, B, C, and D, as described above (1 ≤ A, B, C, D ≤ 109).


Your program should produce a single line. If there is at least a number n for which A, B, C and D make sense, the line must contain the lowest possible n. Otherwise, the line must contain -1.

Input Samples Output Samples

2 12 8 2


3 4 60 105