#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 123;
const int M = 1e7 + 123;
const int inf = 1e9 + 1;
const int mod = 1e9 + 7;
int n, m, a[15], b[15];
vector<int> v;
int main() {
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= m; ++i) {
    cin >> b[i];
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (a[i] == b[j]) {
        v.push_back(a[i]);
      }
    }
  }
  for (int i = 0; i < v.size(); ++i) {
    cout << v[i] << ' ';
  }
  return 0;
}
