Prisoners and Hats Problem