#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, k[12], h;
  map<int, int> p;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &k[i]);
    p[k[i]]++;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &h);
    p[h]++;
  }
  int g = 0;
  for (int i = 0; i < n; i++)
    if (p[k[i]] == 2) {
      printf("%d ", k[i]);
      g = 1;
    }
  if (g == 0) printf("\n");
  return 0;
}
