#include <bits/stdc++.h>
using namespace std;
bool used[15];
int main() {
  int n, m, a[15], b[15];
  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] && used[j] == 0) {
        used[j] = 1;
        cout << a[i] << " ";
      }
    }
  }
}
