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