#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, n[11], m[11];
  scanf("%d%d", &a, &b);
  for (int i = 0; i < a; i++) scanf("%d", &n[i]);
  for (int i = 0; i < b; i++) scanf("%d", &m[i]);
  for (int i = 0; i < a; i++)
    for (int j = 0; j < b; j++) {
      if (n[i] == m[j]) cout << n[i] << " ";
    }
  cout << endl;
  return 0;
}
