Haunted graveyard problem from Kattis. It uses Bellman-Ford