#include<iostream>
using namespace std;
int main(){
int a, b, c, d, x, y;
while(cin>>a>>b>>c>>d&&a>0 && b>0 && c>0 && d>0){
x=a*b; y=c*d;
if(x%y==0)
cout<<x/y<<endl;
else
cout<<-1<<endl;
}
return 0;
}