BubbleRomeoAndJuliet
Romeo and Juliet are in love. However, their families forbid them to meet each other and Juliet wants to see Romeo so much. Luckily, they both live in Bubble Town, and Juliet is allowed to go to sing in a choir on Sunday afternoons. She leaves her home exactly at four o'clock and she must drive using one of the shortest paths to the church. Similarly, Romeo plays football for the Bubble Team at a nearby football stadium every Sunday. He also leaves his home at four o'clock and must follow one of the shortest paths to the stadium. All streets in the Bubble Town are one-way streets.
Every Sunday Juliet hopes that on the way to church she will suddenly see Romeo hurrying to football. However, it has not
happened so far and Juliet does not know whether it is possible at all.
On the second line there are four numbers: JS, JG, RS, RG. Juliet lives at junction JS, church is at junction JG, Romeo's home is at junction RS and the football stadium is at junction RG.
Each of the next m lines contains three integers, a, b and d describing one street, where a and b are numbers of starting and ending junction of this street and d is the time in minutes necessary to drive
from a to b using this street, d ≤ 30. It is possible to go from any junction to any other junction using streets. For a pair of junctions, there are at most two streets connecting them (at most one in each direction).
5 7
1 2 4 5
1 3 5
3 2 7
4 3 5
3 5 8
4 5 13
5 1 9
2 4 6Output
5Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.