missionaries and cannibals problem solution in python