#include <bits/stdc++.h>
int origin[20], n, m, mk;
bool marked[20];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &origin[i]);
  for (int i = 0; i < m; i++) scanf("%d", &mk), marked[mk] = true;
  for (int i = 0; i < n; i++)
    if (marked[origin[i]]) printf("%d ", origin[i]);
  return 0;
}
