http://image3.slideserve.com/5868430/solution-of-the-hat-problem-n.jpg