//浮点错误,按理来说应该是出现了/0或者%0的情况,反复查找不知道错在哪里
//再考虑累乘累加时是否会超出long long的范围,所以改为逐个有理数依次进行求和
/*
#include <iostream>
using namespace std;
const int MAX=100;
long int fun(long int a,long int b);
int main()
{
long int a[MAX],b[MAX];
char c[MAX];
long int A=0,B=1,N,m,k;
cin>>N;
for(int i=0;i<N;i++)
{
cin>>a[i];
cin>>c[i];
cin>>b[i];
}
for(int i=0;i<N;i++)
{
if(b[i]!=0)B*=b[i];//累乘
}
for(int i=0;i<N;i++)
{
if(b[i]!=0)A+=a[i]*(B/b[i]);//累加
}
m=A/B;
A=A-B*m;
if(A==0)cout<<m;
else
{
k=fun(A,B);
long int p=A/k,q=B/k;
if(q<0)p=-p,q=-q;
if(m==0)cout<<p<<"/"<<q<<endl;
else cout<<m<<" "<<p<<"/"<<q<<endl;
}
return 0;
}
long int fun(long int a,long int b)
{
long int temp;
while(a!=0)
{
temp=b%a;
b=a;
a=temp;
}
return b;
}*/
#include <iostream>
using namespace std;
const int MAX=100;
long int fun(long int a,long int b);
int main()
{
long int a[MAX],b[MAX];
char c[MAX];
long int A=0,B=1,N,m,k;
cin>>N;
for(int i=0;i<N;i++)
{
cin>>a[i];
cin>>c[i];
cin>>b[i];
}
A=a[0],B=b[0];
for(int i=1;i<N;i++)
{
int B1=B;
if(b[i]!=0)B*=b[i];
if(b[i]!=0)A=A*(B/B1)+a[i]*(B/b[i]);
if(A==0)A=0,B=1;
else
{
int t;
t=fun(A,B);
A=A/t,B=B/t;
}
}
m=A/B;
A=A-B*m;
if(A==0)cout<<m;
else
{
k=fun(A,B);
A=A/k,B=B/k;
if(B<0)B=-B,A=-A;
if(m==0)cout<<A<<"/"<<B<<endl;
else cout<<m<<" "<<A<<"/"<<B<<endl;
}
return 0;
}
long int fun(long int a,long int b)
{
long int temp;
while(a!=0)
{
temp=b%a;
b=a;
a=temp;
}
return b;
}