/*
TASK: abc
LANG:C++
*/
#include<cstdio>
#include<iostream>
#include<stack>
#include<string>
#include<math.h>
#include<vector>
using namespace std;
int n;

class drob{
  public: 
      int c,z;
};

class niz{
 public:     
  char *s;
};

niz *str;
stack<drob> St;

int nod(int a,int b)
{
    if(b==0) return a;
    return nod(b,a%b);
}

drob norm(drob d){
    d.c/=nod(d.c,d.z);
    d.z/=nod(d.c,d.z);
    return d;
}
drob sum(drob d1,drob d2){
    drob d3; 
     d3.c=d1.c*d2.z+d2.c*d1.z;
     d3.z=d1.z*d2.z;
    return d3;
}

bool pod_triug(char *tmp,int br_el)
{
 int fl,i,h=0,g;
     fl=0;

       for(g=0;(g<br_el)&&(!fl);g++)
        if(tmp[0]==str[g].s[0])
          fl=1;
        if((g==br_el)&&(!fl))
          return 0;
   fl=0;

   for(h=0;h<(strlen(str[g].s))&&(!fl);h++)  
   {

      if(tmp[h]==str[g].s[h])
          fl=1;
   }
   if((h==strlen(str[g].s))&&(!fl))
     return 0;
   else
     return 1;
}

int main()
{
    drob d,res,result;
    int i,fl=0,br_el=0;
    char *tmp;
    scanf("%d",&n);
    str=(niz *)malloc(sizeof(niz)*n);
    scanf("%s",&tmp);
    str[0].s=tmp;
    d.c=1;
    d.z=(int)pow(4,strlen(tmp));
    St.push(d);
    br_el=1;
    for(i=1;i<n;i++)
    {
     scanf("%s",&tmp);
     if(!pod_triug(tmp,br_el))
     {
      str[i].s=tmp; 
      br_el++;
      d.c=1;
      d.z=(int)pow(4,strlen(tmp));
      St.push(d);
     }
    }
    //Do tozi moment v stack sa zapisani licata na triugulnicite,koito ne se povtarqt
    res=St.top();
    St.pop();
    while(!St.empty())
    {
     res=sum(res,St.top());
     St.pop();
    } 
    result=norm(res);
    printf("%d %d",result.c,result.z);
    system("PAUSE");   
    return 0;
}
