s = input()

t = input()

s_memo = {}

t_memo = {}



for i in range(len(s)):

    c1 = s[i]

    c2 = t[i]

    if (c1 in s_memo and s_memo[c1] != c2) or \

            (c2 in t_memo and t_memo[c2] != c1):

        print("No")

        exit()

    s_memo[c1] = c2

    t_memo[c2] = c1



print("Yes")

S = eval(input())

T = eval(input())

Sdictionary = {}

Tdictionary = {}

ans = "Yes"

for i in range(len(S)):

    if T[i] in Tdictionary:

        if Tdictionary[T[i]] == S[i]:

            continue

        else:

            ans = "No"

    else:

        Tdictionary[T[i]] = S[i]

    if S[i] in Sdictionary:

        if Sdictionary[S[i]] == T[i]:

            continue

        else:

            ans = "No"

    else:

        Sdictionary[S[i]] = T[i]





print(ans)

s = input()
t = input()
s_memo = {}
t_memo = {}
for i in range(len(s)):
    c1 = s[i]
    c2 = t[i]
    if (c1 in s_memo and s_memo[c1] != c2) or (c2 in t_memo and t_memo[c2] != c1):
        print("No")
        exit()
    s_memo[c1] = c2
    t_memo[c2] = c1
print("Yes")

S = eval(input())
T = eval(input())
Sdictionary = {}
Tdictionary = {}
ans = "Yes"
for i in range(len(S)):
    if T[i] in Tdictionary:
        if Tdictionary[T[i]] == S[i]:
            continue
        else:
            ans = "No"
    else:
        Tdictionary[T[i]] = S[i]
    if S[i] in Sdictionary:
        if Sdictionary[S[i]] == T[i]:
            continue
        else:
            ans = "No"
    else:
        Sdictionary[S[i]] = T[i]
print(ans)

-s = input() -t = input() -s_memo = {} -t_memo = {} -for i in range(len(s)): -    c1 = s[i] -    c2 = t[i] -    if (c1 in s_memo and s_memo[c1] != c2) or (c2 in t_memo and t_memo[c2] != c1): -        print("No") -        exit() -    s_memo[c1] = c2 -    t_memo[c2] = c1 -print("Yes") +S = eval(input()) +T = eval(input()) +Sdictionary = {} +Tdictionary = {} +ans = "Yes" +for i in range(len(S)): +    if T[i] in Tdictionary: +        if Tdictionary[T[i]] == S[i]: +            continue +        else: +            ans = "No" +    else: +        Tdictionary[T[i]] = S[i] +    if S[i] in Sdictionary: +        if Sdictionary[S[i]] == T[i]: +            continue +        else: +            ans = "No" +    else: +        Sdictionary[S[i]] = T[i] +print(ans)