#include <bits/stdc++.h>
using namespace std;
const int N = 123;
int n;
int a[N], b[N], c[N];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    c[i] = x;
    a[x] = 1;
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (c[i] == b[j]) {
        cout << c[i] << ' ';
      }
    }
  }
  return 0;
}
