#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 3e5 + 10;
long long gcd(long long n, long long m) {
  if (n == 0) {
    return m;
  } else {
    return gcd(m % n, n);
  }
}
long long a, b, x, y;
long long check(long long mid) {
  if (x * mid <= a && y * mid <= b) return 1;
  return 0;
}
long long binsearch(long long lo, long long hi) {
  long long ans = 0;
  while (hi >= lo) {
    long long mid = (lo + hi) / 2;
    if (check(mid)) {
      ans = mid;
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  return ans;
}
int32_t main() {
  cin >> a >> b >> x >> y;
  long long p = gcd(x, y);
  x /= p;
  y /= p;
  if (a < x || b < y) {
    cout << "0 0" << endl;
    return 0;
  }
  long long k = min(a / x, b / y);
  long long kk = binsearch(1, k);
  cout << x * kk << " " << y * kk << endl;
}
