sub f{local($c,$b,$a)=map$$_+pop,c,b,a;${$_="$a $b $c"}//=!/-/&&($n+$a*f(-1,1,0)+$b*f(-1,1)+$c*f(-1))/($a+$b+$c)}$n=<>;${"0 0 0"}=0;$a[$_]++for glob<>;print f@a[0..2]