from string import printable

def main():
    a = list(input("Prima stringa: "))
    b = list(input("Seconda stringa: "))

    both = set()
    ina = set()
    inb = set()
    nowhere = set()

    for char in printable:
        ia = char in a
        iab = char in b

        if ia and iab:
            both.add(char)
        elif ia:
            ina.add(char)
        elif iab:
            inb.add(char)
        else:
            nowhere.add(char)
    
    print(both)
    print(ina)
    print(inb)
    print(nowhere)

    

main()