#pragma GCC optimize ("O3") #pragma GCC target ("avx") #pragma GCC optimize ("Ofast") #include #include #include #include #include using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define FOR(i, m, n) for (int i = (m); i < (n); ++i) #define rrep(i, n) for (int i = (n) - 1; i >= 0; --i) #define rfor(i, m, n) for (int i = (m); i >= (n); --i) #if __has_include("dump.hpp") #define gc _getchar_nolock #define pc _putchar_nolock #include "dump.hpp" #else #define gc getchar_unlocked #define pc putchar_unlocked #define dump(...) ((void)0) #endif inline void ini(int& v)noexcept { char c = gc(); for (; '0' <= c && c <= '9'; c = gc()) { v *= 10; v += c - '0'; } } inline void ini2(int& v)noexcept { char c = gc(); if (c == '?') { gc(); return; } for (; '0' <= c && c <= '9'; c = gc()) { v *= 10; v += c - '0'; } } inline void ins(char* c, int n)noexcept { while (n--) { *c = gc(); ++c; } } int n, k, x; int a[100001], b[100001], c[100001]; int p[100001]; int main() { ini(n); ini(k); ini(x); rep(i, k) { ini2(a[i]); ini2(b[i]); } rep(i, n) { ini(c[i]); } iota(p, p + n, 1); rep(i, n) { if (!a[i])break; swap(p[a[i] - 1], p[b[i] - 1]); } rrep(i, k) { if (!a[i])break; swap(c[a[i] - 1], c[b[i] - 1]); } bool flag = false; rep(i, n) { if (p[i] != c[i]) { printf("%d", i + 1); pc(flag ? '\n' : ' '); flag = true; } } }