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

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

struct node
{
	node* pNodes[4];
	int Value;

	node() {pNodes[0]=pNodes[1]=pNodes[2]=pNodes[3]=NULL; Value=0;}
};

void Read();
void Solve(node* cnode, int depth);
void AddNode(char *s);

int N;
int ch,zn;
node* tree;

int main()
{
	Read();
	Solve(tree,0);

	for(int i=ch;i>1;i--)
		if((ch%i==0) && (zn%i==0))
		{
			ch/=i;
			zn/=i;
			break;
		}

	cout<<ch<<' '<<zn<<endl;

	return 0;
}

void Read()
{
	char x[32];
	cin>>N;

	tree=new node;

	ch=0;
	zn=1;

	for(int i=0;i<N;i++)
	{
		cin>>x;
		AddNode(x);
	}
}

void AddNode(char *s)
{
	int len=strlen(s);

	node* cnode=tree;

	for(int i=0;i<len;i++)
	{
		if(s[i]=='O') s[i]='D';

		if(cnode->pNodes[s[i]-'A']==NULL)
		{
			node* pTemp=new node;
			pTemp->Value=0;
			cnode->pNodes[s[i]-'A']=pTemp;
		}

		cnode=cnode->pNodes[s[i]-'A'];
	}

	cnode->Value=1;
}

void Solve(node* cnode,int depth)
{
	int z=1<<(2*depth);

	if(cnode->Value)
	{
		if((z/zn)<1) 
		{
			ch+=(zn/z);
		}
		else
		{
			ch=ch*(z/zn)+1;
			zn=z;
		}

		return;
	}

	for(z=0;z<4;z++)
		if(cnode->pNodes[z])
			Solve(cnode->pNodes[z],depth+1);
}