#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long m;
  cin >> m;
  long long a[n];
  long long b[m];
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<long long> ans;
  for (long long i = 0; i < m; i++) cin >> b[i];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++)
      if (a[i] == b[j]) ans.push_back(a[i]);
  }
  for (long long i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
