Added partial solution for horizontal/vertical chains. Be aware of infinite loop.