#include <bits/stdc++.h>
using namespace std;
void sprint(string s) {
  for (int i = 0; i < s.size(); ++i) printf("%c", s[i]);
  printf("\n");
}
int b[10];
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    b[x]++;
  }
  for (int i = 0; i < n; ++i) {
    if (b[a[i]] == 1) {
      cout << a[i] << " ";
    }
  }
  cout << endl;
  return 0;
}
