#include<bits/stdc++.h>
using namespace std;
int x,y;
int a[100005],b[100005],c[100005]
int main(){
b[0] = -1;
scanf("%d",&x);
for(int i = 1;i <= x;i++){
scanf("%d",&a[i]);
}
scanf("%d",&y);
for(int i = 1;i <= x;i++){
scanf("%d",&b[i]);
}
printf("%d\n",x);
sort(a + 1,a + x + 1);
sort(b + 1,b + y + 1);
for(int i = 1;i <= x;i++){
c[i] = a[i];
}
for(int i = 1;i <= y;i++){
if(b[i] != c[i]){
c[i] = -1;
}
}
for(int i = 1;i <= y;i++){
if(c[i] != -1){
printf("%d ",c[i]);
}
}
printf("\n");
for(int i = 1;i <= x;i++){
if(a[i] != c[i]){
printf("%d ",a[i]);
}
}
for(int i = 1;i <= x;i++){
if(b[i] != c[i]){
printf("%d ",b[i]);
}
}
return 0;
}