from collections import Counter



S = str(eval(input()))

T = str(eval(input()))



s_counter = Counter(S)

t_counter = Counter(T)



# print(s_counter)

# print(t_counter)



dict_S_to_T = {}

dict_T_to_S = {}



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

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

        dict_S_to_T[s] = t

    else:

        if dict_S_to_T[s] != t:

            print('No')

            exit()

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

        dict_T_to_S[t] = s

    else:

        if dict_T_to_S[t] != s:

            print('No')

            exit()



print('Yes')

S = str(eval(input()))

T = str(eval(input()))



dict_S_to_T = {}

dict_T_to_S = {}



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

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

        dict_S_to_T[s] = t

    else:

        if dict_S_to_T[s] != t:

            print('No')

            exit()

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

        dict_T_to_S[t] = s

    else:

        if dict_T_to_S[t] != s:

            print('No')

            exit()



print('Yes')

from collections import Counter

S = str(eval(input()))
T = str(eval(input()))
s_counter = Counter(S)
t_counter = Counter(T)
# print(s_counter)
# print(t_counter)
dict_S_to_T = {}
dict_T_to_S = {}
for s, t in zip(S, T):
    if s not in list(dict_S_to_T.keys()):
        dict_S_to_T[s] = t
    else:
        if dict_S_to_T[s] != t:
            print("No")
            exit()
    if t not in list(dict_T_to_S.keys()):
        dict_T_to_S[t] = s
    else:
        if dict_T_to_S[t] != s:
            print("No")
            exit()
print("Yes")

S = str(eval(input()))
T = str(eval(input()))
dict_S_to_T = {}
dict_T_to_S = {}
for s, t in zip(S, T):
    if s not in list(dict_S_to_T.keys()):
        dict_S_to_T[s] = t
    else:
        if dict_S_to_T[s] != t:
            print("No")
            exit()
    if t not in list(dict_T_to_S.keys()):
        dict_T_to_S[t] = s
    else:
        if dict_T_to_S[t] != s:
            print("No")
            exit()
print("Yes")

-from collections import Counter - -s_counter = Counter(S) -t_counter = Counter(T) -# print(s_counter) -# print(t_counter)