#include <bits/stdc++.h>
using namespace std;
int binarySearch(int a[], int l, int r, int x);
int main() {
  int n, m, i, temp;
  vector<int> v1;
  vector<int> v2;
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%d", &temp);
    v1.push_back(temp);
  }
  for (i = 0; i < m; i++) {
    scanf("%d", &temp);
    v2.push_back(temp);
  }
  for (i = 0; i < n; i++) {
    if (find(v2.begin(), v2.end(), v1[i]) != v2.end()) {
      printf("%d ", v1[i]);
    }
  }
  printf("\n");
  return 0;
}
