Water Pipe Construction
In the year 21XX, humanity finally began a plan to migrate to Mars. You, who were selected as the first wave of immigrants to Mars, were assigned to the Administrative Center of Mars and are dealing with various problems that occur on Mars. The biggest problem at the moment for the administrative center is to secure a self-sufficient supply and demand cycle. Since it takes several months for aid supplies from the moon to arrive, it is essential to solve the needs on Mars within Mars. In addition, until a circulation system is established, resources must be conserved as much as possible.
The Administrative Center has started mining ice in the polar regions. The ultimate goal is to melt it with solar energy and supply it to each base as water. In the first stage, they decided to lay water pipes from bases with water sources to the two main bases. Also, at present, only some bases and roads connecting them have been developed, and laying water pipes in undeveloped areas requires a significant cost and fuel along the roads, so they decided to lay water pipes along the roads. Furthermore, due to technological constraints, their water pipes always flow in only one direction.
Your job is to create a program that minimizes the cost of laying water pipes under these conditions.
Input
The input consists of multiple datasets.
The first line of each dataset consists of five integers in order: the number of bases n on Mars (3 <= n <= 100), the number of roads m (2 <= m <= 1000) connecting the bases, the number s of the base that serves as the water source, and the numbers g1 and g2 of the two main bases that are the destinations of the water pipes. The base numbers are represented by integers from 1 to n. s, g1, and g2 are distinct.
The following m lines provide information on roads where water pipes can be laid. Each line represents information on a road between two bases, consisting of three integers b1, b2, and c (1 <= c <= 1000). Here, b1 and b2 represent the base numbers at the start and end of the road, respectively, and they are distinct. c is the cost required to lay a water pipe from base b1 to base b2.
For all datasets, it can be assumed that there is always a path to supply water from the source to the destination. Moreover, since there is at most one road between any two bases, cost information is given at most once for each direction.
The end of the input is indicated by a line containing five zeros separated by spaces.
Output
For each dataset, output the minimum cost to lay water pipes on one line.
Sample Input
4 5 1 3 4
1 2 5
2 3 5
2 4 5
1 3 8
1 4 8
0 0 0 0 0
Output for the Sample Input
15
