#include <bits/stdc++.h>
using namespace std;
int n, m;
int arr1[15], arr2[15], vis2[15];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> arr1[i];
  for (int i = 0; i < m; i++) {
    cin >> arr2[i];
    vis2[arr2[i]] = 1;
  }
  for (int i = 0; i < n; i++) {
    if (vis2[arr1[i]]) cout << arr1[i] << ' ';
  }
}
