import java.io.BufferedReader import java.io.InputStream import java.io.InputStreamReader import java.io.PrintWriter import java.util.* fun PrintWriter.solve(sc: FastScanner) { val n = sc.nextInt() val m = sc.nextInt() val p = sc.nextInt() val s = sc.nextInt() - 1 val g = sc.nextInt() - 1 val adj = Array(n) { mutableSetOf() } for (i in 0 until m) { val v1 = sc.nextInt() - 1 val v2 = sc.nextInt() - 1 adj[v1].add(v2) adj[v2].add(v1) } val dist = IntArray(n) { 0 } val que: Queue> = ArrayDeque() val visited = BooleanArray(n) { false } visited[s] = true que.add(s to 0) while (que.count() > 0) { val (v, step) = que.poll() dist[v] = step for (w in adj[v]) { if (visited[w]) continue que.add(w to step + 1) visited[w] = true } } if (p % 2 != dist[g] % 2 || dist[g] > p) { println(-1) return } val dist2 = IntArray(n) { 0 } que.clear() que.add(g to 0) for (i in 0 until n) { visited[i] = i == g } while (que.count() > 0) { val (v, step) = que.poll() dist2[v] = step for (w in adj[v]) { if (visited[w]) continue que.add(w to step + 1) visited[w] = true } } val lst = mutableListOf() for (i in 0 until n) { if (dist[i] + dist2[i] <= p) { lst.add(i + 1) } } println(lst.count()) println(lst.joinToString("\n")) } fun main() { val writer = PrintWriter(System.out, false) writer.solve(FastScanner(System.`in`)) writer.flush() } class FastScanner(s: InputStream) { private var st = StringTokenizer("") private val br = BufferedReader(InputStreamReader(s)) fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() fun ready() = br.ready() }