#include <bits/stdc++.h>
int main() {
  long long int number;
  scanf("%lld", &number);
  getchar();
  long long int search;
  scanf("%lld", &search);
  getchar();
  long long int nomor1[110];
  long long int nomor2[110];
  for (long long int i = 0; i < number; i++) {
    scanf("%lld", &nomor1[i]);
    getchar();
  }
  long long int temp[110];
  for (long long int j = 0; j < search; j++) {
    scanf("%lld", &nomor2[j]);
    getchar();
    temp[j] = 0;
  }
  for (long long int i = 0; i < number; i++) {
    for (long long int j = 0; j < search; j++) {
      if (nomor1[i] == nomor2[j]) {
        printf("%lld ", nomor2[j]);
        temp[i] = 1;
        break;
      }
    }
  }
  return 0;
}
