First version
Second version
Third version
Fourth version (Shunting rule)