/*
TASK:abc
LANG:C
*/

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

void Qsort(char **str,unsigned c)
{
	int b=0,e=c-1;
	char sx[21],sy[21];
	strcpy(sx,str[e/2]);
	do
	{
		while(strcmp(str[b],sx)<0)
			b++;
		while(strcmp(str[e],sx)>0)
			e--;
		if(b<e)
		{
			strcpy(sy,str[b]);
			strcpy(str[b],str[e]);
			strcpy(str[e],sy);
		}
		else
		{
			if(b==e)
			{
				b++;
				e--;
			}
			break;
		}
	}
	while(++b<=--e);
	if(b<c-1)
		Qsort(str+b,c-b);
	if(e>0)
		Qsort(str,e+1);
}

int main()
{
	char **str;
        char f;
	unsigned count;
	unsigned long i,j,k,a,b;

	scanf("%u",&count);
        str=(char **)calloc(sizeof(char *),count);
	for(i=0;i<count;i++)
	{
		str[i]=(char *)calloc(sizeof(char),21);
		scanf("%s",str[i]);
        }
	
	Qsort(str,count);

	a=1;
	b=pow(2,strlen(str[0])+1);
	for(i=0;i<count-1;i++)
	{
        	f=0;
		for(k=0;k<strlen(str[i]);k++)
			if(str[i][k]!=str[i+1][k])
                        	f=1;
                if(f)
		{
			j=pow(2,strlen(str[i+1])+1);
                        a*=j;
			a+=b;
			b*=j;
		}
		for(j=2;j<a/2;j++)
			while((a%j==0)&&(b%j==0))
			{
				a/=j;
				b/=j;
			}
	}

	printf("%ld %ld\n",a,b);
	return 0;
}