#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, m = 0;
  cin >> n >> m;
  int hold_value = 0;
  vector<int> numbers{};
  vector<int> fingerprints = {};
  for (int i = 0; i < n; ++i) {
    cin >> hold_value;
    numbers.push_back(hold_value);
  }
  for (int i = 0; i < m; ++i) {
    cin >> hold_value;
    fingerprints.push_back(hold_value);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (numbers[i] == fingerprints[j]) cout << fingerprints[j] << ' ';
    }
  }
  return 0;
}
