#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
    vector<string> str;
    string s;
    while (cin >> s) {
        str.push_back(s);
    }
    string c_before = str[str.size() - 2], c_after = str[str.size() - 1];
    str.pop_back();
    str.pop_back();
    auto iter = find(str.begin(), str.end(), c_before);
    while (iter != str.end()) {
        str[iter - str.begin()] = c_after;
        iter=find(str.begin(), str.end(), c_before);
    }
    for (string c : str) {
        cout << c << " ";
    }
}
// 64 位输出请用 printf("%lld")