import java.util.Scanner;
class Node{
public int num;
public Node next;
Node(int num,Node node){
this.num = num;
this.next = node;
}
}
public class Main {
public static int minlen;
public static Scanner sn = new Scanner(System.in);
public static void main(String[] args) {
while(sn.hasNext()) {
int ma = sn.nextInt();
Node firsta = new Node(0,null);Node lasta = null;
makeLink(firsta, lasta, ma);
int nb = sn.nextInt();
Node firstb = new Node(0,null);Node lastb = null;
makeLink(firstb, lastb, nb);
for(Node i = firsta.next; i!=null; i = i.next) {
System.out.print(i.num+" ");
lasta = i;
}System.out.println("");
for(Node i = firstb.next; i!=null; i = i.next) {
System.out.print(i.num+" ");
lastb = i;
}System.out.println("");
for(Node i = firstb.next; i!=null; i = i.next) {
int num = i.num;
Node j = firsta.next;
for(; j!=null; j = j.next) {
if(j.num==num)
break;
}
if(j==null) {
Node temp = new Node(num,null);
lasta.next = temp;
lasta = temp;
}
for(Node k = firsta.next; k!=null; k = k.next) {
System.out.print(k.num+" ");
}
System.out.println("");
}
System.out.println("");
}
}
private static void makeLink(Node first, Node last, int n){
last = first;
for(int i=1; i<=n; i++) {
int num = sn.nextInt();
Node node = new Node(num,null);
last.next = node;
last = node;
}
}
}
0.0分
0 人评分