#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  cin >> m;
  int arr1[n];
  vector<int> arr(11, -1);
  for (int i = 0; i < n; i++) {
    cin >> arr1[i];
    arr[arr1[i]] = i;
  }
  set<int> st;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    if (arr[k] != -1) st.insert(arr[k]);
  }
  for (set<int>::iterator it = st.begin(); it != st.end(); it++) {
    cout << arr1[*it] << " ";
  }
  return 0;
}
