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