#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m, i, j, k = 0, w, l, count, max = INT_MIN, min = INT_MAX;
  cin >> n >> m;
  int a[n], b[m], c[n + m];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (a[i] == b[j]) {
        c[k++] = a[i];
      }
    }
  }
  for (i = 0; i < k; i++) {
    cout << c[i] << " ";
  }
  return 0;
}
