#include <bits/stdc++.h>
using namespace std;
int SD() {
  int i;
  scanf("%d", &i);
  return i;
}
long long SLL() {
  long long i;
  scanf("%lld", &i);
  return i;
}
const int AKA = 1e6 + 6;
int a[AKA], b[AKA];
int main() {
  int n = SD(), m = SD();
  for (int i = 0; i < n; ++i) a[i] = SD();
  for (int i = 0; i < m; ++i) b[i] = SD();
  sort(b, b + m);
  for (int i = 0; i < n; ++i)
    if (binary_search(b, b + m, a[i])) printf("%d ", a[i]);
}
