#include <bits/stdc++.h>
using namespace std;
vector<int> v1;
vector<int> v2;
vector<int> v3;
bool ini(vector<int> v, int a) {
  for (int i = 0; i < v.size(); i++) {
    if (v[i] == a) {
      return true;
    }
  }
  return false;
}
int main() {
  int n, m, u, y;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> u;
    v1.push_back(u);
  }
  for (int i = 0; i < m; i++) {
    cin >> y;
    v2.push_back(y);
  }
  for (int i = 0; i < n; i++) {
    if (ini(v2, v1[i])) {
      cout << v1[i] << " ";
    }
  }
}
