#include <bits/stdc++.h>
using namespace std;
int n, m, v[20], x, f[20];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> v[i];
  for (int i = 1; i <= m; i++) cin >> x, f[x] = 1;
  for (int i = 1; i <= n; i++)
    if (f[v[i]]) cout << v[i] << " ";
  cout << endl;
  return 0;
}
