#include<iostream>#include<cstdio>#include<vector>
using namespace std;
bool flag = false;
vector<int> pre, in;voidpost_order(int root,int start,int end){if(start > end || flag == true)return;int i = start;while(i < end && in[i]!= pre[root]) i++;post_order(root+1, start, i-1);post_order(root+i-start+1, i+1, end);if(flag == false){printf("%d", pre[root]);
flag = true;}}intmain(){int n, num;scanf("%d",&n);for(int i =0; i < n; i++){scanf("%d",&num);
pre.push_back(num);}for(int i =0; i < n; i++){scanf("%d",&num);
in.push_back(num);}post_order(0,0, n-1);return0;}