# include <bits/stdc++.h> using namespace std; int main(){ int n, m; scanf("%d", &n); vector<int> va(n); for (int i = 0; i < n; ++i) { scanf("%d", &va[i]); } scanf("%d", &m); vector<int> vb(m); for (int i = 0; i < m; ++i) { scanf("%d", &vb[i]); } vector<int> ans; int indexA = 0, indexB = 0; while (indexA < va.size() && indexB < vb.size()){ if (va[indexA] == vb[indexB]){ ans.push_back(va[indexA]); indexA++; indexB++; } else if (va[indexA] < vb[indexB]){ indexA++; } else{ indexB++; } } for (int i = 0; i < ans.size(); ++i) { if (i != 0) printf(" "); printf("%d", ans[i]); } return 0; }