#include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;
template <typename T>
void printA(vector<T> &printArray, char between = ' ') {
  int paSize = printArray.size();
  for (int i = 0; i < paSize; i++) {
    cerr << printArray[i] << between;
  }
  if (between != '\n') {
    cerr << endl;
  }
}
int a[111], b[111];
int main() {
  int n, m;
  cin >> n >> m;
  for (int(i) = (0); (i) < (n); ++(i)) {
    cin >> a[i];
  }
  for (int(i) = (0); (i) < (m); ++(i)) {
    cin >> b[i];
  }
  vector<int> ans;
  for (int(i) = (0); (i) < (n); ++(i)) {
    for (int(j) = (0); (j) < (m); ++(j)) {
      if (a[i] == b[j]) {
        cout << b[j] << " ";
      }
    }
  }
  cout << endl;
  return 0;
}
