#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, x, m;
  cin >> n >> m;
  long long a[n], b[11] = {};
  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]] == 1) {
      cout << a[i] << " ";
    }
  }
}
