#include <bits/stdc++.h>
using namespace std;
const long long N = 110;
int n, m, seq[N], fin[N], poz;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &seq[i]);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &fin[i]);
  }
  sort(fin + 1, fin + m + 1);
  for (int i = 1; i <= n; i++) {
    poz = lower_bound(fin + 1, fin + m + 1, seq[i]) - fin;
    if (fin[poz] == seq[i]) printf("%d ", seq[i]);
  }
  return 0;
}
