#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  return (a % b == 0 ? b : GCD(b, a % b));
}
long long POW(long long base, long long exp) {
  long long val;
  val = 1;
  while (exp > 0) {
    if (exp % 2 == 1) {
      val = (val * base) % 1000000007;
    }
    base = (base * base) % 1000000007;
    exp = exp / 2;
  }
  return val;
}
int main() {
  long long a, b, x, y, gcd, low, high, mid;
  cin >> a >> b >> x >> y;
  gcd = GCD(x, y);
  x = x / gcd;
  y = y / gcd;
  if (a < x || b < y) {
    printf("0 0\n");
    return 0;
  }
  low = 1;
  high = a / x;
  while (low <= high) {
    mid = (low + high) / 2;
    if (mid * y <= b) {
      if ((mid + 1) * y > b) {
        break;
      } else {
        low = mid + 1;
      }
    } else {
      high = mid - 1;
    }
  }
  a = mid * x;
  b = mid * y;
  cout << a << ' ' << b << '\n';
  return 0;
}
