$R=$C=$_=<>;map{--${$`},$o[$']+=${R^C^$`}if/ .* />$h{$`.$&}++}reverse<>;print$o[$_]+$R*$C,$R=$/for/ /..$'