#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, e, g[109];
bool w[109];
int main() {
  cin >> a >> b;
  for (c = 1; c <= a; c++) {
    cin >> g[c];
  }
  for (c = 1; c <= b; c++) {
    cin >> d;
    w[d] = 1;
  }
  for (c = 1; c <= a; c++) {
    if (w[g[c]] == 1) {
      cout << g[c] << " ";
    }
  }
  return 0;
}
