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