The king arrests all married couples where both spouses are PhDs in Math, Computer Science, or Logic. He holds each couple separate from the others and tells each couple in turn that all the rounded-up PhDs will be put on the parade ground in the morning, each with a hat. Each hat will be the same color... OR... one of two colors... the king will not now mention WHICH colors.
Each couple is in a two-person jail cell and has no communication with other couples from the moment of their arrest. Even on the way to the parade ground and on the parade ground, any communication will result in instant death.
When they reach the parade ground the king will raise his sword. At that moment they must all shout out the color of their hat. And they must ALL be right or ALL be wrong... and if wrong must at least name one of the hat colors. Either way the king will set them free! Otherwise he brings his sword down and the firing squad strikes them dead!
What do they say and why?
(This is a generalization of Guessing hat colors. 4 prisoners)