def get_path_cost(dists, p):
    """
    Get the cost of the shortest path from start -> (bunny permutation) -> end
    """
    current = 0
    cost = 0

    # collect every bunny in order
    for bunny in p:
        cost += dists[current][bunny + 1]
        current = bunny + 1

    # go from the last bunny to the exit
    cost += dists[current][len(dists) - 1]
    return cost