#include <bits/stdc++.h>
using namespace std;
int n, m, x[15], y[15];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> x[i];
  for (int i = 1; i <= m; i++) cin >> y[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (x[i] == y[j]) cout << x[i] << " ";
    }
}
