#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, n;
  cin >> x >> n;
  vector<pair<int, bool>> v;
  for (int i = 0; i < x; i++) {
    int m;
    cin >> m;
    v.push_back(make_pair(m, false));
  }
  for (int i = 0; i < n; i++) {
    int m;
    cin >> m;
    for (int i = 0; i < x; i++)
      if (v[i].first == m) v[i].second = true;
  }
  for (int i = 0; i < v.size(); i++)
    if (v[i].second) cout << v[i].first << " ";
  return 0;
}
