#include #define rep(i, a, n) for(int i = a; i < (n); i++) using namespace std; using ll = long long; using P = pair; const int INF = 1001001001; const ll LINF = 1001002003004005006ll; //const int mod = 1000000007; //const int mod = 998244353; struct Perm : vector { #define n (int)(size()) #define p (*this) Perm(int _n): vector(_n) { iota(begin(), end(), 0); } template Perm(Args...args): vector(args...) {} Perm(initializer_list a): vector(a.begin(),a.end()) {} Perm operator+(const Perm& a) const { Perm r(n); for (int i = 0; i < n; ++i) r[i] = p[a[i]]; return r; } Perm& operator+=(const Perm& a) { return *this = (*this)+a; } Perm operator-() const { Perm r(n); for (int i = 0; i < n; ++i) r[p[i]] = i; return r; } Perm operator-(const Perm& a) const { return *this + -a; } Perm& operator-=(const Perm& a) { return *this += -a; } // next permutation bool operator++() { return next_permutation(begin(),end()); } #undef n #undef p }; int main() { const int n = 5; vector a(n), b(n); rep(i, 0, n) { cin >> a[i]; a[i]--; } rep(i, 0, n) { cin >> b[i]; b[i]--; } Perm p(a); p += b; rep(i, 0, n) cout << p[i]+1 << " \n"[i == n-1]; return 0; }