#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
bool a[70], b[70], flag;
int x, y, n;
int main() {
cin >> x;
for (int i = 1; i <= 63; i++) {
a[i] = 0;
b[i] = 0;
}
for (int i = 0; i < x; i++) {
cin >> n;
a[n] = 1;
}
cin >> y;
for (int i = 0; i < y; i++) {
cin >> n;
b[n] = 1;
}
cout << x << endl;
for (int i = 0; i <= 63; i++)
if (a[i] && b[i])cout << i << " ";
cout << endl;
for (int i = 0; i <= 63; i++)
if (a[i] || b[i])cout << i << " ";
cout << endl;
for (int i = 0; i <= 63; i++)
if (a[i] == 0)cout << i << " ";
cout << endl;
for (int i = 0; i <= 63; i++) {
if (a[i] && b[i])flag = 1;
else flag = 0;
}
if (flag)cout << 1 << endl;
else cout << 0 << endl;
flag = 1;
for (int i = 0; i <= 63; i++)
if (a[i] && b[i] == 0)flag = 0;
if (flag)cout << 1 << endl;
else cout << 0 << endl;
if (a[0])cout << 1<<endl;
else cout << 0<<endl;
return 0;
}