#include <bits/stdc++.h>
using namespace std;
#define SZ(X) ((int)X.size())
#define mp make_pair
#define pb push_back
#define RALL(X) X.rbegin(),X.rend()
#define ALL(X) X.begin(),X.end()
using ll = long long ;
using ld = long double ;
const int N = 1E6 + 7;
vector<int> vec_intersection(vector<int>&v1, vector<int>&v2)
{
int i = 0, j = 0;
vector<int> v3;
while(i < SZ(v1) && j < SZ(v2)) {
if(v1[i] == v2[j]) {
v3.pb(v1[i]);
++ i;
++ j;
} else if(v1[i] > v2[j]) {
++ j;
} else {
++ i;
}
}
v3.erase(unique(ALL(v3)), v3.end());
return v3;
}
vector<int> vec_union(vector<int>&v1, vector<int>&v2)
{
int i = 0, j = 0;
vector<int> v3;
while(i < SZ(v1) && j < SZ(v2)) {
if(v1[i] == v2[j]) {
v3.pb(v1[i]);
++ i;
++ j;
} else if(v1[i] > v2[j]) {
v3.pb(v2[j ++]);
} else {
v3.pb(v1[i ++]);
}
}
while(i < SZ(v1)) v3.pb(v1[i ++]);
while(j < SZ(v2)) v3.pb(v2[j ++]);
v3.erase(unique(ALL(v3)), v3.end());
return v3;
}
int main()
{
int n, m, tmp;
while(scanf("%d%d",&n,&m) != EOF) {
for(int i = 0; i < m; ++ i) scanf("%d",&v2[i]);
/*
v3 = vec_intersection(v1, v2);
v3 = vec_union(v1, v2);
*/
set_intersection(ALL(v1),ALL(v2),back_inserter(v3)); //交集
//set_union(ALL(v1),ALL(v2),back_inserter(v3)); //并集
n = SZ(v3);
if(v3.empty()) {
puts("empty");
continue;
}
for(int i = 0; i < n; i ++) {
printf("%d%c",v3[i],i==n-1?'\n':' ');
}
}
return 0;
}
using namespace std;
#define SZ(X) ((int)X.size())
#define mp make_pair
#define pb push_back
#define RALL(X) X.rbegin(),X.rend()
#define ALL(X) X.begin(),X.end()
using ll = long long ;
using ld = long double ;
const int N = 1E6 + 7;
vector<int> vec_intersection(vector<int>&v1, vector<int>&v2)
{
int i = 0, j = 0;
vector<int> v3;
while(i < SZ(v1) && j < SZ(v2)) {
if(v1[i] == v2[j]) {
v3.pb(v1[i]);
++ i;
++ j;
} else if(v1[i] > v2[j]) {
++ j;
} else {
++ i;
}
}
v3.erase(unique(ALL(v3)), v3.end());
return v3;
}
vector<int> vec_union(vector<int>&v1, vector<int>&v2)
{
int i = 0, j = 0;
vector<int> v3;
while(i < SZ(v1) && j < SZ(v2)) {
if(v1[i] == v2[j]) {
v3.pb(v1[i]);
++ i;
++ j;
} else if(v1[i] > v2[j]) {
v3.pb(v2[j ++]);
} else {
v3.pb(v1[i ++]);
}
}
while(i < SZ(v1)) v3.pb(v1[i ++]);
while(j < SZ(v2)) v3.pb(v2[j ++]);
v3.erase(unique(ALL(v3)), v3.end());
return v3;
}
int main()
{
int n, m, tmp;
while(scanf("%d%d",&n,&m) != EOF) {
vector<int>v1(n),v2(m),v3;
// 要求输入有序
for(int i = 0; i < m; ++ i) scanf("%d",&v2[i]);
/*
v3 = vec_intersection(v1, v2);
v3 = vec_union(v1, v2);
*/
set_intersection(ALL(v1),ALL(v2),back_inserter(v3)); //交集
//set_union(ALL(v1),ALL(v2),back_inserter(v3)); //并集
n = SZ(v3);
if(v3.empty()) {
puts("empty");
continue;
}
for(int i = 0; i < n; i ++) {
printf("%d%c",v3[i],i==n-1?'\n':' ');
}
}
return 0;
}