#include <bits/stdc++.h>
int s[300], n, m, cnt;
int b[300];
int ans[300];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    s[i] = x;
  }
  for (int i = 1; i <= m; ++i) {
    int x;
    scanf("%d", &x);
    b[i] = x;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (s[i] == b[j]) {
        ans[++cnt] = s[i];
        break;
      }
    }
  }
  for (int i = 1; i <= cnt; ++i) {
    printf("%d ", ans[i]);
  }
  return 0;
}
