missionaries and cannibals problem code in python