/*
TASK: abc
LANG:C++
*/

#include <iostream>
#include <stdlib.h>
#include <map>
#include <string>
#include <vector>
using namespace std;


vector<string> v[4];
map<string,bool> used;
pair<unsigned,unsigned> l,Sum,NotAdd;
unsigned N,k;
bool term;



void Check(string S)
{    
     if(S[0]=='O') k=0;
     if(S[0]=='A') k=1;
     if(S[0]=='B') k=2;
     if(S[0]=='C') k=3;
     
     if(v[k].empty()) { v[k].push_back(S); used[S]=true; }
     
     for(int i=0;i<v[k].size();i++)
     {
          if( S.length()<v[k][i].length() ) { l.first=S.length(); l.second=1; }
          else { l.first= v[k][i].length(); l.second=2; }
          
          for(int j=0;j<l.first;j++)
             if(S[j]!=v[k][i][j]) { term=true; break; }
          
          if(term && !used[S]) { v[k].push_back(S); used[S]=true; }
          else
              if(l.second==1) 
                 if(!used[S]) { v[k][i]=S; used[S]=true; }
                 else v[k].erase(v[k].begin()+i);
          
          term=false;
     }
}

int GCD(int a,int b)
{
int t;
    while(b!=0)
    {
       t=a%b;
       a=b;
       b=t;
    }
    return a;
}

void Add(unsigned t)
{
int gcd;
     
     Sum.first*=t;
     Sum.first+=Sum.second;
     Sum.second*=t;
     
     gcd=GCD(Sum.first,Sum.second);
     Sum.first/=gcd;
     Sum.second/=gcd;
}

void Read()
{
string s;
     
     Sum.first=0; Sum.second=1;
     
     cin>>N;
     for(int i=0;i<N;i++)
     {
         cin>>s;
         Check(s);
     }
     
//     cout<<endl;
     for(int k=0;k<4;k++)
     {
        for(int i=0;i<v[k].size();i++)
        {
//            cout<<v[k][i]<<"   ";
            Add(v[k][i].length()*4);
        }
//        cout<<endl;
     }
//     system("pause");
     
}

void Write()
{
     
     cout<<Sum.first<<" "<<Sum.second<<"\n";
     
//     system("pause");
}

int main()
{ 
    Read();
    
    Write();
    
    return 0;
}
