Evil warlock dislikes dwarfs and therefore he selects four of them and buries them. The dwarfs are buried in the ground and they are in such a way that except for their heads, their body is inside the ground. The dwarfs cannot move their body and they can view only forward. They are all buried in a line, and amongst the four, one of the dwarfs is separated by a wall. All the dwarfs are in the same direction. The last dwarfs can see two heads of friends in the front and a wall. In the last second dwarf can see one head of his friend and a wall. The second dwarf can see only the wall. The dwarf can see nothing.
Warlock comprehends the situation and tells the dwarfs that he has placed hats on their heads. There are two blue hats and two red ones. In all four dwarfs, one of them has to say what colour hat he is wearing. If the dwarf says the correct colour of the hat, they will be left free. If the answer is wrong, then they will be dug inside the ground till the very end.
What will be the answer by the dwarf and how will they answer?