import java.util.Scanner;
import java.util.TreeSet;
public class 集合运算 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
TreeSet<Integer> treeSetA = new TreeSet<Integer>();
int n = in.nextInt();
for (int i = 0; i < n; i++) {
treeSetA.add(in.nextInt());
}
TreeSet<Integer> treeSetB = new TreeSet<Integer>();
int m = in.nextInt();
for (int i = 0; i < m; i++) {
treeSetB.add(in.nextInt());
}
in.close();
printDivide(treeSetA, treeSetB);
printAdd(treeSetA, treeSetB);
printRemain(treeSetA, treeSetB);
}
public static void printAdd(TreeSet<Integer> a, TreeSet<Integer> b) {
a.addAll(b);
for (int i : a) {
System.out.print(i + " ");
}
System.out.println();
}
public static void printDivide(TreeSet<Integer> a, TreeSet<Integer> b) {
@SuppressWarnings("unchecked")
TreeSet<Integer> tempA = (TreeSet<Integer>) a.clone();
a.removeAll(b);
tempA.removeAll(a);
for (int i : tempA) {
System.out.print(i + " ");
}
System.out.println();
}
public static void printRemain(TreeSet<Integer> a, TreeSet<Integer> b) {
a.removeAll(b);
for (int i : a) {
System.out.print(i + " ");
}
System.out.println();
}
}
import java.util.Scanner;
import java.util.TreeSet;
public class Demo1两个集合 {
public static void main(String[] args) {
TreeSet<Integer> seta = new TreeSet<Integer>();
TreeSet<Integer> setb = new TreeSet<Integer>();
TreeSet<Integer> setab = new TreeSet<Integer>();
int temp=0;
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 0; i < n; i++) {
seta.add(sc.nextInt());
}
setab.addAll(seta);
int m = sc.nextInt();
for (int i = 0; i < m; i++) {
temp=sc.nextInt();
if(seta.add(temp)){
}else{
setb.add(temp);
}
}
sc.close();
setab.removeAll(setb);
for(int i:setb){
System.out.print(i+" ");
}
if(setb.size()!=0)
System.out.println();
for(int i:seta){
System.out.print(i+" ");
}
if(seta.size()!=0)
System.out.println();
for(int i:setab){
System.out.print(i+" ");
}
}
}