#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  int val;
  int vect[100];
  for (int i = 0; i < n; ++i) {
    cin >> vect[i];
  }
  vector<int> v;
  for (int i = 0; i < m; ++i) {
    cin >> val;
    mp[val] = 1;
  }
  for (int i = 0; i < n; ++i) {
    if (mp[vect[i]] == 1) v.push_back(vect[i]);
  }
  for (int i = 0; i < v.size(); ++i) {
    cout << v[i] << " ";
  }
}
