S = eval(input())

T = eval(input())



tToS = {}

sToT = {}

for s, t in zip(S, T):

    if not t in tToS:

        tToS[t] = s

    if not s in sToT:

        sToT[s] = t



    if tToS[t] != s or sToT[s] != t:

        print('No')

        exit()



print('Yes')

S = eval(input())

T = eval(input())



def isOk():

    sToT = {}

    tToS = {}

    for s, t in zip(S, T):

        if not s in sToT:

            sToT[s] = t

        elif sToT[s] != t:

            return False

        if not t in tToS:

            tToS[t] = s

        elif tToS[t] != s:

            return False

    return True



print(('Yes' if isOk() else 'No'))

S = eval(input())
T = eval(input())
tToS = {}
sToT = {}
for s, t in zip(S, T):
    if not t in tToS:
        tToS[t] = s
    if not s in sToT:
        sToT[s] = t
    if tToS[t] != s or sToT[s] != t:
        print("No")
        exit()
print("Yes")

S = eval(input())
T = eval(input())


def isOk():
    sToT = {}
    tToS = {}
    for s, t in zip(S, T):
        if not s in sToT:
            sToT[s] = t
        elif sToT[s] != t:
            return False
        if not t in tToS:
            tToS[t] = s
        elif tToS[t] != s:
            return False
    return True


print(("Yes" if isOk() else "No"))

-tToS = {} -sToT = {} -for s, t in zip(S, T): -    if not t in tToS: -        tToS[t] = s -    if not s in sToT: -        sToT[s] = t -    if tToS[t] != s or sToT[s] != t: -        print("No") -        exit() -print("Yes") + + +def isOk(): +    sToT = {} +    tToS = {} +    for s, t in zip(S, T): +        if not s in sToT: +            sToT[s] = t +        elif sToT[s] != t: +            return False +        if not t in tToS: +            tToS[t] = s +        elif tToS[t] != s: +            return False +    return True + + +print(("Yes" if isOk() else "No"))