{
TASK:abc
LANG:PASCAL
}

var
  a: array[1..1000] of String;
  vis: array[1..1000] of Boolean;
  n,i,j,k: Integer;
  now: String;
  s1,s2,c: Longint;

begin
  readln(n);
  for i:= 1 to n do
  begin
    readln(a[i]);
    vis[i]:= false;
  end;
  s1:= 1; s2:= 1;

  for i:= 1 to n do
    if not vis[i] then
    begin
      now:= a[i];
      for j:= i+1 to n do
      begin
        if length(a[j])<length(now) then
          if pos(a[j],now) = 1 then
            now:= a[j];

        if length(a[j])>= length(now) then
          if pos(now,a[j]) = 1 then
            vis[j]:= true;
      end;
      c:= (length(now)+1)*(length(now)+1);
      if s2<c then
      begin
        s1:= s1*(c mod s2) + 1;
        s2:= c;
      end
      else
        if s2=c then
          s1:= s1+1
        else
          s1:= s1 + (s2 mod c);
    end;
  for k:= 2 to s2-1 do
    if (s1 mod k = 0) and (s2 mod k = 0) then
    begin
      s1:= s1 div k;
      s2:= s2 div k;
    end;
  writeln(s1,' ',s2);
end.
















