Under construction

Still being built. Things may change

Meeting Point

Interview

Time limit0.5sMemory limit1024 MB

Summary
Given a weighted road graph, list every crossroad X where the shortest distance from P to X is twice the P-to-G distance and every shortest path to X passes through G.
Level

Medium6 of 10

Topics
Shortest path, Graph, DFS
Solved
No attempts yet

Problem

Your friend Pedro always gets very excited for group activities. In his excitement, he runs so fast to the meeting point that he gets tired before arriving.

One day, you decided to gather data on this phenomenon. You noticed that he consistently gets tired exactly at the midpoint of his route. In other words, he gets tired when he has traveled half the distance he was going to travel.

Your city has NN crossroads identified by distinct integers from 11 to NN, and MM two-way roads. Each road has a length and connects a specific pair of crossroads. There is a path in the city between every pair of crossroads. The distance between two crossroads is the length of a shortest path between them.

Pedro lives at crossroad PP, and your group of friends decided to meet at crossroad GG later today. You devised the following plan so that Pedro arrives on time. You will tell him a misleading meeting point so that he gets tired exactly at GG. For this plan to work, crossroad GG must belong to every path that Pedro could take from PP to the misleading meeting point. For each such path, Pedro must get tired exactly at GG. Pedro is a good planner and would never take a path longer than needed.

Which crossroads would work as that misleading meeting point?

Input

The first line contains two integers NN (2≤N≤1052 \le N \le 10^5) and MM (1≤M≤1051 \le M \le 10^5), the number of crossroads and the number of roads. Each crossroad is identified by a distinct integer from 11 to NN.

The second line contains two integers PP and GG (1≤P,G≤N1 \le P, G \le N, P≠GP \ne G), the crossroad where Pedro lives and the correct meeting point.

Each of the next MM lines describes a road with three integers UU, VV and DD (1≤U,V≤N1 \le U, V \le N, U≠VU \ne V, 1≤D≤1091 \le D \le 10^9), meaning there is a two-way road of length DD between crossroads UU and VV.

The graph is connected. There is at most one road between each pair of crossroads.

Output

Output a single line with an increasing list of integers, the crossroads that would work as the misleading meeting point. If no crossroad works, output the character * (asterisk) instead.

Examples4

  1. Example 1

    Input
    4 5
    1 3
    1 3 1
    2 1 3
    2 4 3
    4 3 1
    3 2 1
    
    Expected output
    2 4
    
  2. Example 2

    Input
    4 5
    1 3
    1 3 1
    2 1 2
    2 4 3
    4 3 1
    3 2 1
    
    Expected output
    4
    
  3. Example 3

    Input
    3 2
    1 2
    1 2 100000
    2 3 99999
    
    Expected output
    *
    
  4. Example 4

    Input
    4 4
    4 3
    3 4 1
    4 1 1
    1 2 1
    2 3 1
    
    Expected output
    *