#include <iostream>
#include <cmath>
using namespace std;
int a, b, l1, r1, l2, r2, ansX, ansY;
double aOverb, xOvery, ansXOverY = 10000000;
int main() {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
cin >> a >> b >> l1 >> r1 >> l2 >> r2;
aOverb = (double) a / b;
for (int x = l1; x <= r1; ++x) {
int l = l2, r = r2, y;
while (l <= r) {
y = (l + r) / 2;
xOvery = (double) x / y;
if (xOvery == aOverb) {
cout << x << " " << y << endl;
return 0;
}
else if (xOvery < aOverb) {
r = y - 1;
}
else {
l = y + 1;
}
}
if (abs(xOvery - aOverb) < abs(ansXOverY - aOverb)) {
ansX = x;
ansY = y;
ansXOverY = (double) x / y;
}
}
cout << ansX << " " << ansY << endl;
}
Copy