You have N computers ( to N) and M connections. Find the shortest path from computer to computer N, or report if impossible.
Print the number of computers in the path and the path itself.
This is a standard shortest path problem. Think about which technique applies here. The graph is unweighted (all connections cost ), so you should consider which traversal finds shortest paths in unweighted graphs. You also need to reconstruct the actual path, not just compute the distance.