#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int digit[n], fingerprint[m];
  for (int i = 0; i < n; i++) cin >> digit[i];
  for (int i = 0; i < m; i++) cin >> fingerprint[i];
  sort(fingerprint, fingerprint + m);
  for (int i = 0; i < n; i++)
    if (binary_search(fingerprint, fingerprint + m, digit[i]))
      cout << digit[i] << " ";
  cout << " ";
}
