#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int a[n], b[m];
  for (size_t i = 0; i < n; i++) cin >> a[i];
  for (size_t i = 0; i < m; i++) cin >> b[i];
  for (size_t i = 0; i < n; i++)
    for (size_t j = 0; j < m; j++)
      if (a[i] == b[j]) cout << a[i] << " ";
}
