message passing in toh

per derek's implementation in nqueens.