#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(NULL), cout.tie(0);
  int a, b;
  cin >> a >> b;
  int c[a], d[b], l = 0, e[b];
  for (int i = 0; i < a; i++) cin >> c[i];
  for (int i = 0; i < b; i++) cin >> d[i];
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < b; j++) {
      if (c[i] == d[j]) {
        e[l] = c[i];
        l++;
      }
    }
  }
  for (int i = 0; i < l; i++) cout << e[i] << " ";
  return 0;
}
