while(0<1)println{val Array(a,b,m,n)=readLine split' 'map(_.toInt) a to(m*n,m)find(_%n==b)getOrElse-1}