S = eval(input())

T = eval(input())





from collections import Counter





s_dict, t_dict = {}, {}



for i in range(len(S)):

    if S[i] in list(s_dict.keys()):

        if s_dict[S[i]] != T[i]:

            print("No")

            exit()

    else:

        s_dict[S[i]] = T[i]



    if T[i] in list(t_dict.keys()):

        if t_dict[T[i]] != S[i]:

            print("No")

            exit()

    else:

        t_dict[T[i]] = S[i]



print("Yes")

S = eval(input())

T = eval(input())



s_dict, t_dict = {}, {}



for i in range(len(S)):

    if S[i] in list(s_dict.keys()):

        if s_dict[S[i]] != T[i]:

            print("No")

            exit()

    else:

        s_dict[S[i]] = T[i]



    if T[i] in list(t_dict.keys()):

        if t_dict[T[i]] != S[i]:

            print("No")

            exit()

    else:

        t_dict[T[i]] = S[i]



print("Yes")

S = eval(input())
T = eval(input())
from collections import Counter

s_dict, t_dict = {}, {}
for i in range(len(S)):
    if S[i] in list(s_dict.keys()):
        if s_dict[S[i]] != T[i]:
            print("No")
            exit()
    else:
        s_dict[S[i]] = T[i]
    if T[i] in list(t_dict.keys()):
        if t_dict[T[i]] != S[i]:
            print("No")
            exit()
    else:
        t_dict[T[i]] = S[i]
print("Yes")

S = eval(input())
T = eval(input())
s_dict, t_dict = {}, {}
for i in range(len(S)):
    if S[i] in list(s_dict.keys()):
        if s_dict[S[i]] != T[i]:
            print("No")
            exit()
    else:
        s_dict[S[i]] = T[i]
    if T[i] in list(t_dict.keys()):
        if t_dict[T[i]] != S[i]:
            print("No")
            exit()
    else:
        t_dict[T[i]] = S[i]
print("Yes")

-from collections import Counter -