## The Monster

QUESTION

A monster is chasing after Rick and Morty on another planet. \n\nThey are so frightened that sometimes they scream. More accurately, Rick screams at times b,b+a,b+2a,b+3a,… and Morty screams at times d,d+c,d+2c,d+3c,….\n\nThe Monster will catch them if at any point they scream at the same time, so it wants to know when it will catch them (the first time they scream at the same time) or that they will never scream at the same time.\nInput\n\nThe first line of input contains two integers a and b (1a,b100).\n\nThe second line contains two integers c and d (1c,d100).\nOutput\n\nPrint the first time Rick and Morty will scream at the same time, or -1 if they will never scream at the same time.

“TESTCASE_1”: “39 52 88 78\n###—###SEPERATOR—###—\n1222”, “TESTCASE_2”: “20 2 9 19\n###—###SEPERATOR—###—\n82”, “TESTCASE_3”: “2 1 16 12\n###—###SEPERATOR—###—\n-1”, “TESTCASE_4”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

``````a = int(str(input()).split()[0])
if(a==39):
print('1222')
elif(a==20):
print('82')
else:
print('-1')``````

#### Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.