#include <bits/stdc++.h>
using namespace std;
int n, m, a[10], b[10], i, x;
int main() {
  cin >> n >> m;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < m; i++) {
    cin >> x;
    b[x] = 1;
  }
  for (i = 0; i < n; i++)
    if (b[a[i]]) cout << a[i] << " ";
  cout << endl;
  return 0;
}
