not working solution
working solution with BFS + map/reduce