#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int arr1[15];
  int arr2[15];
  int arr3[15];
  cin >> n >> m;
  memset(arr3, -1, sizeof(arr3));
  for (int i = 0; i < n; i++) {
    cin >> arr1[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> arr2[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr2[j] == arr1[i]) {
        arr3[i] = arr1[i];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (arr3[i] == -1)
      continue;
    else
      cout << arr3[i] << " ";
  }
  return 0;
}
