import collections

s = eval(input())

t = eval(input())

dd = collections.defaultdict(str)

dd2 = collections.defaultdict(str)

for i in range(len(s)):

    if dd[t[i]] == '':

        dd[t[i]] = s[i]

    if dd[t[i]] != '' and dd[t[i]] != s[i]:

        print('No')

        exit()

for i in range(len(s)):

    if dd2[s[i]] == '':

        dd2[s[i]] = t[i]

    if dd2[s[i]] != '' and dd2[s[i]] != t[i]:

        print('No')

        exit()

print('Yes')
import collections

s = eval(input())

t = eval(input())

dd = collections.defaultdict(str)

dd2 = collections.defaultdict(str)

for i in range(len(s)):

    key = s[i]

    key2 = t[i]

    if dd[key] != '' and dd[key] != key2 or dd2[key2] != '' and dd2[key2] != key:

        print('No')

        exit()

    dd[key] = key2

    dd2[key2] = key

print('Yes')
import collections

s = eval(input())
t = eval(input())
dd = collections.defaultdict(str)
dd2 = collections.defaultdict(str)
for i in range(len(s)):
    if dd[t[i]] == "":
        dd[t[i]] = s[i]
    if dd[t[i]] != "" and dd[t[i]] != s[i]:
        print("No")
        exit()
for i in range(len(s)):
    if dd2[s[i]] == "":
        dd2[s[i]] = t[i]
    if dd2[s[i]] != "" and dd2[s[i]] != t[i]:
        print("No")
        exit()
print("Yes")

import collections

s = eval(input())
t = eval(input())
dd = collections.defaultdict(str)
dd2 = collections.defaultdict(str)
for i in range(len(s)):
    key = s[i]
    key2 = t[i]
    if dd[key] != "" and dd[key] != key2 or dd2[key2] != "" and dd2[key2] != key:
        print("No")
        exit()
    dd[key] = key2
    dd2[key2] = key
print("Yes")

-    if dd[t[i]] == "": -        dd[t[i]] = s[i] -    if dd[t[i]] != "" and dd[t[i]] != s[i]: +    key = s[i] +    key2 = t[i] +    if dd[key] != "" and dd[key] != key2 or dd2[key2] != "" and dd2[key2] != key: -for i in range(len(s)): -    if dd2[s[i]] == "": -        dd2[s[i]] = t[i] -    if dd2[s[i]] != "" and dd2[s[i]] != t[i]: -        print("No") -        exit() +    dd[key] = key2 +    dd2[key2] = key