BearPermutations2

TopCoder - 14084