#include <bits/stdc++.h>
using namespace std;
int arr[20];
map<int, bool> mp;
int main() {
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  for (int i = 0; i < m; i++) {
    int x;
    scanf("%d", &x);
    mp[x] = 1;
  }
  for (int i = 0; i < n; i++) {
    if (mp[arr[i]]) printf("%d ", arr[i]);
  }
}
