uva11730: BFS in an implicit graph.