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')
s = eval(input())

t = eval(input())

d = {}

for si, ti in zip(s, t):

    if si in d:

        if d[si] != ti:

            print('No')

            exit()

    else:

        d[si] = ti

l = len(set(d.values()))

print(('Yes' if len(d) == l else 'No'))
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")

s = eval(input())
t = eval(input())
d = {}
for si, ti in zip(s, t):
    if si in d:
        if d[si] != ti:
            print("No")
            exit()
    else:
        d[si] = ti
l = len(set(d.values()))
print(("Yes" if len(d) == l else "No"))

-import collections - -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") +d = {} +for si, ti in zip(s, t): +    if si in d: +        if d[si] != ti: +            print("No") +            exit() +    else: +        d[si] = ti +l = len(set(d.values())) +print(("Yes" if len(d) == l else "No"))