#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a, b;
  cin >> a >> b;
  int arr_a[a], arr_b[b];
  for (int i = 0; i < a; i++) {
    cin >> arr_a[i];
  }
  for (int i = 0; i < b; i++) {
    cin >> arr_b[i];
  }
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < b; j++) {
      if (arr_a[i] == arr_b[j]) {
        cout << arr_a[i] << " ";
        break;
      }
    }
  }
  cout << endl;
  return 0;
}
