using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Magatro { static int N, K, X; static string[] A, B; static int[] C; static void Main() { int[] q = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); N = q[0]; K = q[1]; X = q[2]; A = new string[K]; B = new string[K]; for (int i = 0; i < K; i++) { string[] s = Console.ReadLine().Split(' '); A[i] = s[0]; B[i] = s[1]; } C = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); int[] start = new int[N]; for (int i = 1; i <= N; i++) { start[i-1] = i; } for (int i = 0; A[i] != "?"; i++) { int d = start[int.Parse(A[i])-1]; start[int.Parse(A[i])-1] = start[int.Parse(B[i])-1]; start[int.Parse(B[i])-1] = d; } for (int i = K - 1; A[i] != "?"; i--) { int d = C[int.Parse(A[i])-1]; C[int.Parse(A[i])-1] = C[int.Parse(B[i])-1]; C[int.Parse(B[i])-1] = d; } int cnt = 0; for (int i = 0; i < N; i++) { if (start[i] != C[i]) { if (cnt == 0) { Console.Write(i + 1 + " "); } else { Console.Write(1 + i); } } // Console.WriteLine(start[i] + " " + C[i]); } } }