($N,$K)=glob<>; @_=(0)x$K; / .* /,${$`}[$&]++or++${$`},$_[$'-1]+=$N-${$`^v17}for reverse<>; shift@_;$N*=$N;$N-=$_ for@_;$,=$/;print$N,@_