#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(m);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int j = 0; j < m; ++j) cin >> b[j];
  for (int i = 0; i < n; ++i) ++a[i];
  for (int j = 0; j < m; ++j) ++b[j];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (a[i] == b[j]) a[i] = -a[i];
    }
  }
  for (int i = 0; i < n; ++i)
    if (a[i] < 0) cout << -a[i] - 1 << " ";
  cout << endl;
  return 0;
}
