#include <bits/stdc++.h>
using namespace std;
int a[100];
bool Is[100];
int main() {
  int n, m, b;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) {
    cin >> b;
    Is[b] = 1;
  }
  for (int i = 1; i <= n; i++)
    if (Is[a[i]]) printf("%d ", a[i]);
}
