import heapq
INF = int(1e9)
n, m, k, x = map(int, input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
a, b = map(int, input().split())
g[a].append(b)
d = [INF] * (n+1)
def dijkstra(start):
q = []
heapq.heappush(q, (0, start))
d[start] = 0
while q:
dist, now = heapq.heappop(q)
if d[now] < dist:
continue
for i in g[now]:
cost = dist + 1
if cost < d[i]:
d[i] = cost
heapq.heappush(q, (cost, i))
dijkstra(x)
ans = 1
for i in range(1, n+1):
if d[i] == k:
print(i)
ans = 0
if ans:
print(-1)
다익스트라로 해결, pypy 제출