Task composition with manhattan distance heuristic