#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int arr[10] = {0};
  int farr[10] = {0};
  scanf("%d %d\n", &n, &m);
  int j = 1;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d ", &x);
    arr[x] = j++;
  }
  for (int i = 0; i < m; i++) {
    int x;
    scanf("%d ", &x);
    farr[x] = 1;
  }
  for (int k = 1; k < 11; k++) {
    for (int i = 0; i < 10; i++) {
      if (arr[i] == k && farr[i] == 1) {
        printf("%d ", i);
      }
    }
  }
  return 0;
}
