#include <bits/stdc++.h>
using namespace std;
int ch[20], n, a[20], b, m;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b;
    ch[b] = 1;
  }
  for (int i = 0; i < n; i++) {
    if (ch[a[i]] == 1) {
      cout << a[i] << endl;
    }
  }
  return 0;
}
