185. Two shortest
time limit per test: 0.25
sec.
memory limit per test: 4096
KB
input: standard input
output: standard output
Yesterday Vasya and Petya quarreled badly, and now they don't want to see each other on their way to school. The problem is that they live in one and the same house, leave the house at the same time and go at the same speed by the shortest road. Neither of them wants to change their principles, that is why they want to find two separate shortest routes, which won't make them go along one road, but still they can meet at any junction. They ask you to help them. They number all the junctions with numbers from 1 to N (home and school are also considered as junctions). So their house has the number 1 and the school has the number N, each road connects two junctions exactly, and there cannot be several roads between any two junctions.
Input
The first line contains two integer numbers N and M (2<=N<=400), where M is the number of roads Petya and Vasya noticed. Each of the following M lines contains 3 integers: X, Y and L (1<=X, Y<=N, 1<=L<=10000), where X and Y  numbers of junctions, connected by the road and L is the length of the road.
Output
Write to the first line numbers of the junctions in the way they passed them on the first route. Write to the second line numbers of the junctions in the way they passed them on the second route. If it is impossible to help guys, then output "No solution".
Sample test(s)
Input
6 8
1 2 1
3 2 1
3 4 1
1 3 2
4 2 2
4 5 1
5 6 1
4 6 2
Output
1 3 4 5 6
1 2 4 6
Author:  Andrew V. Lazarev

Resource:  ACM International Collegiate Programming Contest 20032004
NorthEastern European Region, Southern Subregion

Date:  2003 October, 9

Server time: 20141129 11:22:47  Online Contester Team © 2002  2014. All rights reserved. 

