#include <bits/stdc++.h>
int main() {
  int num[15];
  int fin[15];
  int pad = 0, mark = 0;
  scanf("%d %d", &pad, &mark);
  for (int i = 0; i < pad; i++) {
    scanf("%d", &num[i]);
  }
  for (int i = 0; i < mark; i++) {
    scanf("%d", &fin[i]);
  }
  int count = 0;
  for (int i = 0; i < pad; i++) {
    for (int j = 0; j < mark; j++) {
      if (num[i] == fin[j]) {
        if (count == 0) {
          printf("%d", num[i]);
        } else {
          printf(" %d", num[i]);
        }
        count++;
        break;
      }
    }
  }
  puts("");
  return 0;
}
