#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int fp[100], a[100], n, m, k;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    cin >> k;
    fp[k] = true;
  }
  for (int i = 0; i < n; i++) {
    if (fp[a[i]] == true) v.push_back(a[i]);
  }
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  return 0;
}
