#!/usr/bin/env python n = int(input().strip()) sorder = [int(x) for x in input().split()] forder = [int(x) for x in input().split()] index = 0 for team in forder: tmp = sorder.index(team) if tmp < index: continue else: index = tmp print(team)