#include <iostream>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b) {
while (b != 0) {
ll tmp = b;
b = a % b;
a = tmp;
}
return a;
}
struct PhanSo {
ll tu, mau;
void rutgon() {
ll div = gcd(abs(tu), abs(mau));
tu /= div;
mau /= div;
if (mau < 0) {
tu = -tu; mau = -mau;
}
}
};
PhanSo Cong (PhanSo a, PhanSo b) {
return {a.tu * b.mau + b.tu * a.mau, a.mau * b.mau};
}
PhanSo Tru (PhanSo a, PhanSo b) {
return {a.tu * b.mau - b.tu * a.mau, a.mau * b.mau};
}
PhanSo Nhan(PhanSo a, PhanSo b) {
return {a.tu * b.tu, a.mau * b.mau};
}
PhanSo Chia (PhanSo a, PhanSo b) {
return {a.tu * b.mau, a.mau * b.tu};
}
void HienThi (PhanSo p) {
p.rutgon();
cout << p.tu << '/' << p.mau << ' ';
}
void Input(PhanSo &p) {
cin >> p.tu >> p.mau;
}
int main() {
PhanSo A, B;
Input(A); Input(B);
HienThi(Cong(A, B));
HienThi(Tru(A, B));
HienThi(Nhan(A, B));
HienThi(Chia(A, B));
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp1c2luZyBsbCA9IGxvbmcgbG9uZzsKCmxsIGdjZChsbCBhLCBsbCBiKSB7CiAgICB3aGlsZSAoYiAhPSAwKSB7CiAgICAgICAgbGwgdG1wID0gYjsKICAgICAgICBiID0gYSAlIGI7CiAgICAgICAgYSA9IHRtcDsKICAgIH0KICAgIHJldHVybiBhOwp9CnN0cnVjdCBQaGFuU28gewogICAgbGwgdHUsIG1hdTsKICAgIAogICAgdm9pZCBydXRnb24oKSB7CiAgICAgICAgbGwgZGl2ID0gZ2NkKGFicyh0dSksIGFicyhtYXUpKTsKICAgICAgICB0dSAvPSBkaXY7CiAgICAgICAgbWF1IC89IGRpdjsKICAgICAgICBpZiAobWF1IDwgMCkgewogICAgICAgICAgICB0dSA9IC10dTsgbWF1ID0gLW1hdTsKICAgICAgICB9C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