#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[11], b[11];
bool dd[11];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int j = 1; j <= m; ++j) cin >> b[j];
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (a[i] == b[j]) dd[i] = 1;
  for (int i = 1; i <= n; ++i)
    if (dd[i] == 1) cout << a[i] << " ";
}
