A person was travelling in the middle of an empty road.
As he walked, he saw five doors, with guards in front of each one.
He had no other way of crossing the road.
The first guard said, "If all the other four tell the truth, then so shall I. Pass through my door, it is safe."
The second guard said, "Whom you ask before me, if he has lied, then so will I. Pass through my door, it is safe."
He then asked the third guard, who replied, "You shall ask a guard after me. Shall he say the truth, and the first guard doesn't lie, I shall not lie. Shall he say falsehood, and the first guard doesn't lie, I shall say the truth. In other cases, I shall always be a liar. Pass through my door, it is safe."
When he asked the fourth guard, the fourth guard replied, "If the number of liars is more than the number of truth tellers, I shall lie. If the number of truth tellers is more, I shall tell the truth. Pass through my door, it is safe."
When the fifth guard was questioned, he replied, "If guards 2 and 4 lie, I shall not lie. Pass through my door, it is safe."
Guards will only lie about which door is safe. They won't lie about other things.
There is only one actually safe door. Which one is it?