#include <iostream>

using namespace std;

struct rational
{ int top, bot; };

rational fraction(int t, int b)
{ rational r;
  r.top = t;
  r.bot = b;
  return r; }

void print(rational r)
{ cout << r.top << "/" << r.bot; }

rational multiply(rational a, rational b)
{ rational r;
  r.top = a.top * b.top;
  r.bot = a.bot * b.bot;
  return r; }

rational divide(rational a, rational b)
{ rational r;
  r.top = a.top * b.bot;
  r.bot = a.bot * b.top;
  return r; }

rational add(rational a, rational b)
{ rational r;
  r.top = a.top * b.bot + b.top * a.bot;
  r.bot = a.bot * b.bot;
  return r; }

rational subtract(rational a, rational b)
{ rational r;
  r.top = a.top * b.bot - b.top * a.bot;
  r.bot = a.bot * b.bot;
  return r; }

void one_test(string s, rational a, rational b, rational c)
{ print(a);
  cout << " " << s << " ";
  print(b);
  cout << " is ";
  print(c);
  cout << "\n"; }

void test(rational a, rational b)
{ one_test("plus", a, b, add(a, b));
  one_test("minus", a, b, subtract(a, b));
  one_test("times", a, b, multiply(a, b));
  one_test("divided by", a, b, divide(a, b)); }

rational ask(string prompt)
{ rational r;
  cout << prompt << ", top then bottom: ";
  cin >> r.top >> r.bot;
  return r; }

int main()
{ while (true)
  { rational a = ask("A");
    rational b = ask("B");
    test(a, b); } }