#include <bits/stdc++.h>
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int x[n], y[m];
  for (int i = 0; i < n; i++) scanf("%d", x + i);
  for (int i = 0; i < m; i++) scanf("%d", y + i);
  bool exist = 0;
  for (int i = 0; i < n; i++) {
    exist = 0;
    for (int j = 0; j < m; j++)
      if (x[i] == y[j]) exist = 1;
    if (exist) printf("%d ", x[i]);
  }
}
