#include<stdio.h>
#include<string.h>
int main()
{
int n1,n2,m,i,j,m1,sum;
char a[100],b[100];
while(scanf("%s",a)&&a[0]!='-')
{
scanf("%s",b);
n1=strlen(a);
n2=strlen(b);
m1=0;
// if(n1>=n2)
{
for(i=0,j=0;i<=n1;i++){m=0;
for(j=0;j<n2&&i+j<n1;j++)
if(a[i+j]==b[j])
m++;
if(m>m1) m1=m;}
}
// else
{
for(i=0,j=0;i<=n2;i++){m=0;
for(j=0;j<n1&&i+j<n2;j++)
if(b[i+j]==a[j])
m++;
if(m>m1) m1=m;}
}
sum=n1+n2;
m=m1*2;
printf("appx(%s,%s)",a,b);
printf(" = ");
if(m==0) printf("0\n");
else if(m==sum) printf("1\n");
else if(sum%m==0) printf("1/%d\n",sum/m);
else
{
while(m%2==0&&sum%2==0)
{
m=m/2;
sum=sum/2;
}
while(m%3==0&&sum%3==0)
{
m=m/3;
sum=sum/3;
}
printf("%d/%d\n",m,sum);
}
}
return 0;
}