n, k, x = map(int, input().split()) place = [i + 1 for i in range(n)] ab = [input().split() for _ in range(k)] for a, b in ab: if a == "?": break a, b = int(a) - 1, int(b) - 1 place[a], place[b] = place[b], place[a] clst = list(map(int, input().split())) for a, b in ab[::-1]: if a == "?": break a, b = int(a) - 1, int(b) - 1 clst[a], clst[b] = clst[b], clst[a] ans = [] for i, (bef, aft) in enumerate(zip(place, clst), start = 1): if bef != aft: ans.append(i) ans.sort() print(*ans)