sub g{$_[1]?g($_[1],"@_"%$_[1]):"@_"} sub f{!$_[2]?$s+=(($==$h/$_[1])-=$l/$_[1])*$_*($_%2*2-1):"@_"<$n?(f("@_"+1,$_[1]*$c[$_[0]]/g($_[1],$c[$_[0]]),$_[2]-1),f("@_"+1,$_[1],$_[2])):0;} ($n,$l,$h,@c)=glob<>.<>;$l--; f 0,1,$_ for 1..$n; print$s