#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("interclasare3.in");
ofstream fout("interclasare3.out");
int main()
{
int a[100001], b[100001], c[300000], n, m, k=0, i, j;
fin>>n>>m;
for(i=1; i<=n; i++)
fin>>a[i];
for(i=m; i>=1; i--)
fin>>b[i];
i=j=1;
while(i<=n&&j<=m)
if(a[i]%2==0)
if(b[j]%2==0)
{
if(a[i]<b[j])
c[++k]=a[i++];
else
c[++k]=b[j++];
}
else
j++;
else
i++;
while(i<=n)
if(a[i]%2==0)
c[++k]=a[i++];
else
i++;
while(j<=m)
if(b[j]%2==0)
c[++k]=b[j++];
else
j++;
n=0;
for(i=1; i<=k; i++)
{
fout<<c[i]<<" ";
n++;
if(n%20==0)
fout<<endl;
}
return 0;
}