#include <bits/stdc++.h>
using namespace std;
int main() {
  int nums[10];
  int n, m, x;
  int seq[10];
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> seq[i];
  for (int j = 0; j < m; j++) {
    cin >> nums[j];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (seq[i] == nums[j]) {
        cout << seq[i] << " ";
        break;
      }
    }
  }
  return 0;
}
