#include <bits/stdc++.h>
using namespace std;
int n, m;
map<int, int> mp;
int a[11], aa[11];
int b[11];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (a[b[i]] == 0) {
      a[b[i]]++;
      mp[b[i]]++;
    }
  }
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    if (aa[x] == 0) {
      aa[x]++;
      mp[x]++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (mp[b[i]] == 2) cout << b[i] << ' ';
  }
  return 0;
}
