@lines = <>;

$n=1000;
$long = '';
srand;
# generating one random sequence of length $n:
while ($n--){
	$long .= qw<( )>[int (rand()*2) ]
	}
	
$m;
$m = qr/\((?:|(??{$m})++)*\)/;

for (@lines, $long){
	undef %occ;
	map { ++$occ{(length)} } /$m+/g;
	$max = 0;
	$max < $_ and $max = $_ for keys %occ;
	print $max," ",$occ{$max} || 1,$/;
	}