#include <bits/stdc++.h>
using namespace std;
int a[15];
int vis[15];
int main() {
  int N, M;
  while (cin >> N >> M) {
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= N; i++) cin >> a[i];
    int x;
    for (int i = 1; i <= M; i++) {
      cin >> x;
      vis[x] = 1;
    }
    for (int i = 1; i <= N; i++) {
      if (vis[a[i]]) cout << a[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
