#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); }
int main() {
  int i, sum, m, n, a, b, j = 0;
  scanf("%d%d%d%d", &m, &n, &a, &b);
  if (a > b) {
    swap(a, b);
    j = 1;
  }
  sum = gcd(a, b);
  a /= sum, b /= sum;
  if (j == 1) swap(a, b);
  if (m < a || n < b) {
    printf("0 0\n");
    return 0;
  }
  sum = min(m / a, n / b);
  printf("%d %d", a * sum, b * sum);
}
