package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func next() string { sc.Split(bufio.ScanWords) if !sc.Scan() { panic("could not scan a word from the reader") } return sc.Text() } func nextInt() int { i, e := strconv.Atoi(next()) if e != nil { panic(e) } return i } var inf = 1 << 29 func min(x, y int) int { if y < x { return y } return x } var d, e [210][210]int func main() { N, M, S, G := nextInt(), nextInt(), nextInt(), nextInt() for i := 0; i < N; i++ { for j := 0; j < N; j++ { if i != j { d[i][j] = inf } } } for i := 0; i < M; i++ { A, B, C := nextInt(), nextInt(), nextInt() d[A][B], d[B][A], e[A][B], e[B][A] = C, C, C, C } for k := 0; k < N; k++ { for i := 0; i < N; i++ { for j := 0; j < N; j++ { d[i][j] = min(d[i][j], d[i][k]+d[k][j]) } } } var res []int res = append(res, S) cur := S t := 0 for cur != G { for next := 0; next < N; next++ { if e[cur][next] > 0 && t+e[cur][next]+d[next][G] == d[S][G] { t += e[cur][next] cur = next res = append(res, next) break } } } for i := 0; i < len(res); i++ { fmt.Printf("%d", res[i]) if i < len(res)-1 { fmt.Printf(" ") } else { fmt.Println() } } }