S=eval(input())

T=eval(input())



Rs = {}

Rt = {}



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

    

    if s in list(Rs.keys()) and Rs[s] != t:

        print("No")

        exit()

    if t in list(Rt.keys()) and Rt[t] != s:

        print("No")

        exit()



    if not s in list(Rs.keys()):

        Rs[s] = t

    if not t in list(Rt.keys()):

        Rt[t] = s



ress = [""] * len(S)

rest = [""] * len(S)

for i,s in enumerate(S):

    ress[i] = Rs[s]



for i,t in enumerate(T):

    rest[i] = Rt[t]

print(("Yes" if "".join(ress)==T and "".join(rest)==S else "No"))
S=eval(input())

T=eval(input())



Rs = {}

Rt = {}



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

    

    if s in list(Rs.keys()) and Rs[s] != t:

        print("No")

        exit()

    if t in list(Rt.keys()) and Rt[t] != s:

        print("No")

        exit()



    if not s in list(Rs.keys()):

        Rs[s] = t

    if not t in list(Rt.keys()):

        Rt[t] = s



ress = [""] * len(S)

for i,s in enumerate(S):

    ress[i] = Rs[s]



print(("Yes" if "".join(ress)==T else "No"))
S = eval(input())
T = eval(input())
Rs = {}
Rt = {}
for s, t in zip(S, T):
    if s in list(Rs.keys()) and Rs[s] != t:
        print("No")
        exit()
    if t in list(Rt.keys()) and Rt[t] != s:
        print("No")
        exit()
    if not s in list(Rs.keys()):
        Rs[s] = t
    if not t in list(Rt.keys()):
        Rt[t] = s
ress = [""] * len(S)
rest = [""] * len(S)
for i, s in enumerate(S):
    ress[i] = Rs[s]
for i, t in enumerate(T):
    rest[i] = Rt[t]
print(("Yes" if "".join(ress) == T and "".join(rest) == S else "No"))

S = eval(input())
T = eval(input())
Rs = {}
Rt = {}
for s, t in zip(S, T):
    if s in list(Rs.keys()) and Rs[s] != t:
        print("No")
        exit()
    if t in list(Rt.keys()) and Rt[t] != s:
        print("No")
        exit()
    if not s in list(Rs.keys()):
        Rs[s] = t
    if not t in list(Rt.keys()):
        Rt[t] = s
ress = [""] * len(S)
for i, s in enumerate(S):
    ress[i] = Rs[s]
print(("Yes" if "".join(ress) == T else "No"))

-rest = [""] * len(S) -for i, t in enumerate(T): -    rest[i] = Rt[t] -print(("Yes" if "".join(ress) == T and "".join(rest) == S else "No")) +print(("Yes" if "".join(ress) == T else "No"))