#include <stdio.h>

int main() {
    int n1, n2;

    // Read the size of the first list
    scanf("%d", &n1);
    
    // If n1 or n2 is invalid, print "Invalid input"
    if (n1 <= 0) {
        printf("Invalid input\n");
        return 0;
    }

    int list1[n1];
    
    // Read the elements of the first list
    for (int i = 0; i < n1; i++) {
        scanf("%d", &list1[i]);
    }

    // Read the size of the second list
    scanf("%d", &n2);
    
    // If n1 or n2 is invalid, print "Invalid input"
    if (n2 <= 0) {
        printf("Invalid input\n");
        return 0;
    }

    int list2[n2];
    
    // Read th