#include <iostream>
#include <math.h>
using namespace std;
class Ulamek
  {
   private:
   long L,M;
   static long NWD(long A,long B);
   void Normalizuj();
   public:
   Ulamek():L(0),M(1) {}
   Ulamek(long L,long M):L(L),M(M) { Normalizuj(); }
   long l()const { return L; }
   long m()const { return M; }
   Ulamek operator-(const Ulamek &B)const;
   Ulamek operator-()const { return Ulamek(-L,M); }
  };

long Ulamek::NWD(long A,long B)
  {
   while(B)
     {

      long R=A%B;
      A=B;
      B=R;
     }
   return A?A:1;
  }

void Ulamek::Normalizuj()
  {
   if(M<0) { L=-L; M=-M; }
   long D=NWD(abs(L),M);
   L/=D;
   M/=D;
  }

Ulamek Ulamek::operator-(const Ulamek &B)const
  {
   return Ulamek(L*B.M-B.L*M,M*B.M);
  }

Ulamek operator+(const Ulamek &A,const Ulamek &B)
  {
   return Ulamek(A.l()*B.m()+B.l()*A.m(),A.m()*B.m());
  }

ostream &operator<<(ostream &out,const Ulamek &u)
  {
   return out<<u.l()<<'/'<<u.m();
  }

int main()
  {
   Ulamek A(1,2),B(3,4),C,D;

   C=A+B;
   D=A-B;

   cout<<A<<'+'<<B<<'='<<C<<';'<<endl;
   cout<<A<<'-'<<B<<'='<<D<<';'<<endl;
   cout<<(-D)<<endl;

   cin.get();
   return 0;
  }

