#include <iostream>

struct Fraction {
    int numerator, denominator;
};

int gcd(int a, int b) {
    while (b != 0) {
        int temp = b;
        b = a % b;
        a = temp;
    }
    return a;
}

Fraction simplify(const Fraction& f) {
    int g = gcd(f.numerator, f.denominator);
    return {f.numerator / g, f.denominator / g};
}

Fraction add(const Fraction& f1, const Fraction& f2) {
    int newNumerator = f1.numerator * f2.denominator + f2.numerator * f1.denominator;
    int newDenominator = f1.denominator * f2.denominator;
    return simplify({newNumerator, newDenominator});
}

Fraction subtract(const Fraction& f1, const Fraction& f2) {
    int newNumerator = f1.numerator * f2.denominator - f2.numerator * f1.denominator;
    int newDenominator = f1.denominator * f2.denominator;
    return simplify({newNumerator, newDenominator});
}

Fraction multiply(const Fraction& f1, const Fraction& f2) {
    int newNumerator = f1.numerator * f2.numerator;
    int newDenominator = f1.denominator * f2.denominator;
    return simplify({newNumerator, newDenominator});
}

Fraction divide(const Fraction& f1, const Fraction& f2) {
    int newNumerator = f1.numerator * f2.denominator;
    int newDenominator = f1.denominator * f2.numerator;
    return simplify({newNumerator, newDenominator});
}

void printFraction(const Fraction& f) {
    std::cout << f.numerator << "/" << f.denominator << std::endl;
}

int main() {
    Fraction f1 = {1, 2};
    Fraction f2 = {3, 4};
    printFraction(add(f1, f2));
    printFraction(subtract(f1, f2));
    printFraction(multiply(f1, f2));
    printFraction(divide(f1, f2));
    return 0;
}

