#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int e = 0;
  int d;
  int a[15], b[15], l[10];
  for (int f = 0; f < n; f++) cin >> a[f];
  for (int j = 0; j < m; j++) cin >> b[j];
  int rr = 0, tt = 0;
  for (int g = 0; g < n; g++) {
    if (a[g] < 0 || a[g] > 9) {
      for (int r = g; r < n; r++) a[r] = a[r + 1];
      rr++;
    }
  }
  for (int h = 0; h < m; h++) {
    if (b[h] < 0 || b[h] > 9) {
      for (int t = h; t < m; t++) b[t] = b[t + 1];
      tt++;
    }
  }
  if (n >= 0 && n <= 10 && m >= 0 && m <= 10) {
    for (int c = 0; c < n - rr; c++) {
      for (int d = 0; d < m - tt; d++) {
        if (a[c] == b[d]) {
          l[e] = a[c];
          e++;
        }
      }
    }
    for (int k = 0; k < e; k++) cout << l[k] << " ";
  }
}
