#include<bits/stdc++.h>
using namespace std;
#define el "\n"
#define ll long long
#define ull unsigned long long
#define se second
#define fi first
#define be begin()
#define en end()
#define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
struct PhanSo
{
int tu, mau;
};
PhanSo tong(const PhanSo& ps1, const PhanSo& ps2)
{
int tu, mau, tmp;
PhanSo ans;
tmp = ps1.mau /__gcd(ps1.mau, ps2.mau) * ps2.mau;
ans.mau = tmp;
ans.tu = ps1.tu*(tmp / ps1.mau) + ps2.tu*(tmp / ps2.mau);
tmp = __gcd(ans.tu, ans.mau);
ans.tu /= tmp;
ans.mau /= tmp;
return ans;
}
bool ssLonHon(const PhanSo& ps1, const PhanSo& ps2)
{
double a = 1.0 * ps1.tu / ps1.mau;
double b = 1.0 * ps2.tu / ps2.mau;
if(a > b) return true;
return false;
}
int main()
{
Faster;
PhanSo a, b;
cin >> a.tu >> a.mau >> b.tu >> b.mau;
PhanSo x = tong(a, b);
cout << x.tu << " " << x.mau << " ";
if(ssLonHon(a, b)) cout << "true";
else cout << "no";
return 0;
}
/*
#include <bits/stdc++.h>
using namespace std;
struct PhanSo {
int tu, mau;
};
void rutGon(PhanSo &ps) {
int gcd = __gcd(abs(ps.tu), abs(ps.mau));
ps.tu /= gcd;
ps.mau /= gcd;
if (ps.mau < 0) {
ps.tu = -ps.tu;
ps.mau = -ps.mau;
}
}
PhanSo tong(const PhanSo &ps1, const PhanSo &ps2) {
PhanSo ans;
int lcm = ps1.mau / __gcd(ps1.mau, ps2.mau) * ps2.mau;
ans.tu = ps1.tu * (lcm / ps1.mau) + ps2.tu * (lcm / ps2.mau);
ans.mau = lcm;
rutGon(ans);
return ans;
}
bool ssLonHon(const PhanSo &ps1, const PhanSo &ps2) {
int lcm = ps1.mau / __gcd(ps1.mau, ps2.mau) * ps2.mau;
int tu1 = ps1.tu * (lcm / ps1.mau);
int tu2 = ps2.tu * (lcm / ps2.mau);
return tu1 > tu2;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
PhanSo a, b;
cin >> a.tu >> a.mau >> b.tu >> b.mau;
rutGon(a);
rutGon(b);
PhanSo x = tong(a, b);
cout << x.tu << " " << x.mau << " ";
if (ssLonHon(a, b)) {
cout << "true";
} else {
cout << "false";
}
return 0;
}
*/
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBlbCAiXG4iCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgdWxsIHVuc2lnbmVkIGxvbmcgbG9uZwojZGVmaW5lIHNlIHNlY29uZAojZGVmaW5lIGZpIGZpcnN0CiNkZWZpbmUgYmUgYmVnaW4oKQojZGVmaW5lIGVuIGVuZCgpCiNkZWZpbmUgRmFzdGVyIGNpbi50aWUoMCk7IGNvdXQudGllKDApOyBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwoKc3RydWN0IFBoYW5Tbwp7CiAgICBpbnQgdHUsIG1hdTsKfTsKClBoYW5TbyB0b25nKGNvbnN0IFBoYW5TbyYgcHMxLCBjb25zdCBQaGFuU28mIHBzMikKewogICAgaW50IHR1LCBtYXUsIHRtcDsKICAgIFBoYW5TbyBhbnM7CiAgICB0bXAgPSBwczEubWF1IC9fX2djZChwczEubWF1LCBwczIubWF1KSAqIHBzMi5tYXU7CiAgICBhbnMubWF1ID0gdG1wOwogICAgYW5zLnR1ID0gcHMxLnR1Kih0bXAgLyBwczEubWF1KSArIHBzMi50dSoodG1wIC8gcHMyLm1hdSk7CiAgICB0bXAgPSBfX2djZChhbnMudHUsIGFucy5tYXUpOwogICAgYW5zLnR1IC89IHRtcDsKICAgIGFucy5tYXUgLz0gdG1wOwogICAgcmV0dXJuIGFuczsKfQoKYm9vbCBzc0xvbkhvbihjb25zdCBQaGFuU28mIHBzMSwgY29uc3QgUGhhblNvJiBwczIpCnsKICAgIGRvdWJsZSBhID0gMS4wICogcHMxLnR1IC8gcHMxLm1hdTsKICA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