1 #include <iostream>
2 #include <cstring>
3 using namespace std;
4
5 long long gcd(long long a,long long b)
6 {
7 long long temp;
8 while (a%b)
9 {
10 temp=a%b;
11 a=b;
12 b=temp;
13 }
14 if (b>0)
15 return b;
16 else
17 return -b;
18 }
19 void out(long long a,long long b)
20 {
21 if (a>0&&b<0)
22 {
23 a=-a;
24 b=-b;
25 }
26 if (a<0&&b<0)
27 {
28 a=-a;
29 b=-b;
30 }
31 if (b==0)
32 {
33 cout <<"Inf";
34 return;
35 }
36 long long t=gcd(a,b);
37 a=a/t;
38 b=b/t;
39 long long c=a/b;
40 if (b==1)
41 {
42 if (a<0)
43 cout <<"("<<a<<")";
44 else
45 cout <<a;
46 }
47 else
48 {
49 if (a<0)
50 {
51 cout <<"(";
52 if(c!=0)
53 {
54 cout <<c<<" ";
55 if (a<0)
56 a=-a;
57 a=a%b;
58 }
59 cout <<a<<"/"<<b<<")";
60 }
61 else
62 {
63 if(c!=0)
64 {
65 cout <<c<<" ";
66 if (a<0)
67 a=-a;
68 a=a%b;
69 }
70 cout <<a<<"/"<<b;
71 }
72 }
73 return;
74 }
75 int main()
76 {
77 long long a1,b1,a2,b2,a,c;
78 char ch;
79 while (cin>>a1>>ch>>b1)
80 {
81 cin>>a2>>ch>>b2;
82
83 out(a1,b1);
84 cout <<" + ";
85 out(a2,b2);
86 cout <<" = ";
87 out(a1*b2+b1*a2,b1*b2);
88 cout <<endl;
89
90 out(a1,b1);
91 cout <<" - ";
92 out(a2,b2);
93 cout <<" = ";
94 out(a1*b2-b1*a2,b1*b2);
95 cout <<endl;
96
97 out(a1,b1);
98 cout <<" * ";
99 out(a2,b2);
100 cout <<" = ";
101 out(a1*a2,b1*b2);
102 cout <<endl;
103
104 out(a1,b1);
105 cout <<" / ";
106 out(a2,b2);
107 cout <<" = ";
108 out(a1*b2,b1*a2);
109 cout <<endl;
110 }
111 return 0;
112 }