def operate(x,y,T): for t,k in T: if t==1: x+=k*y else: y+=k*x return x,y def solve(): from math import gcd a,b,c,d=map(int,input().split()) if gcd(a,b)!=gcd(c,d): print(-1) return if gcd(a,b)==0: print(0) return def euclid(a,b): res=[] while a and b: if abs(a)>abs(b): k=abs(a)//abs(b) x=a+k*b; y=a-k*b if abs(x)