#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[10], t, s[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    a[s[i]] = -1;
  }
  for (int i = 0; i < m; i++) {
    cin >> t;
    if (a[t] == -1) a[t] = -2;
  }
  for (int i = 0; i < n; i++) {
    if (a[s[i]] == -2) cout << s[i] << " ";
  }
  return 0;
}
