#include <bits/stdc++.h>
using namespace std;
int dp[11];
int main() {
  int n, m, e, a[20];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> e;
    dp[e] = 1;
  }
  for (int i = 0; i < n; i++) {
    if (dp[a[i]]) {
      cout << a[i] << " ";
      dp[a[i]] = 0;
    }
  }
  cout << "\n";
  return 0;
}
