#include <bits/stdc++.h>
using namespace std;
void solution() {
  int sequence, finger_p, input;
  cin >> sequence >> finger_p;
  vector<int> seq, fp;
  while (sequence--) {
    cin >> input;
    seq.push_back(input);
  }
  while (finger_p--) {
    cin >> input;
    fp.push_back(input);
  }
  for (auto i : seq) {
    for (auto j : fp) {
      if (i == j) {
        cout << i << " ";
      }
    }
  }
}
int main() {
  solution();
  return 0;
}
