#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int a , b , l1 , r1 , l2 , r2;
double ans = 1e18;
int ansx , ansy;
double val2;
inline void check(int x,int y){
double val = (double)x / y;
if(abs(val - val2) < ans){
ans = abs(val - val2);
ansx = x;
ansy = y;
}
}
int main(){
cin >> a >> b >> l1 >> r1 >> l2 >> r2;
val2 = (double)a / b;
long long tmpVal;
for(int y = l2;y <= r2;y++){
check(l1 , y);
check(r1 , y);
tmpVal = (long long)a * y / b;
for(long long j = tmpVal - 3;j <= tmpVal + 3;j++){
if(j <= (long long)r1 && j >= (long long)l1)
check(j , y);
}
}
cout << ansx << " " << ansy << endl;
}
Copy