import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        // Read number of elements
        int n = sc.nextInt();
        int[] arr = new int[n];
        
        // Read sequence elements
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        
        // Read oldVal and newVal
        int oldVal = sc.nextInt();
        int newVal = sc.nextInt();
        
        // Replace oldVal with newVal in the array
        for (int i = 0; i < n; i++) {
            if (arr[i] == oldVal) {
                arr[i] = newVal;
            }
        }
        
        // Output the updated array
        for (int i = 0; i < n; i++) {
            System.out.print(arr[i]);
            if (i != n - 1) {
                System.out.print(" ");
            }
        }
    }
}