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