#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, k = 0;
  int a[15], b[15], c[15];
  cin >> m >> n;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  for (int j = 0; j < n; j++) {
    cin >> b[j];
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (b[j] == a[i]) c[k++] = a[i];
    }
  }
  if (!k)
    cout << endl;
  else {
    for (int i = 0; i < k - 1; i++) {
      cout << c[i] << ' ';
    }
    cout << c[k - 1];
  }
  return 0;
}
