Four men walk into the desert. Suddenly all four are simultaneously knocked out. They awake buried to their heads in the sand unable to look anywhere but straight ahead. They are positioned so that each man sees another's head before him. However between the first and second man there is a separating wall. So the first man sees only desert. The second man sees only wall. The third man sees another's head and a wall. The fourth man sees two heads and a wall. On top of each mans head is a hat. The underside of each cap is black, but the outside of each cap is either blue or white. Before any of the men can speak, their captors tell them if they speak, they die. However, if any of them can guess the color of their cap on the first try they go free. The captors tell them that there are two blue caps and two white caps. Being an omniscient observer of the situation, we know that the order of the caps are: blue, white, blue, white. So knowing the perspective of each man in the sand, and that they can only see the color of caps/wall/desert in front of them.
Which of the four men knows for certain the color of his own cap. More importantly: why?