s = list(eval(input()))

t = list(eval(input()))

s_set = list(set(s))

t_set = list(set(t))

l = len(s)

l_s_set = len(s_set)

l_t_set = len(t_set)



x = [[] for _ in range(l)]

for i in range(l):

    x[i].append(s[i])

    x[i].append(t[i])



for j in range(l_s_set):

    tmp = []

    for k in range(l):

        if s_set[j] == x[k][0]:

            tmp.append(x[k][1])

    if len(set(tmp)) > 1:

        print('No')

        exit()



for p in range(l_t_set):

    tmp = []

    for q in range(l):

        if t_set[p] == x[q][1]:

            tmp.append(x[q][0])

    if len(set(tmp)) > 1:

        print('No')

        exit()



print('Yes')
s = list(eval(input()))

t = list(eval(input()))

s_set = list(set(s))

t_set = list(set(t))



for j in range(len(s_set)):

    tmp = []

    for k in range(len(s)):

        if s_set[j] == s[k]:

            tmp.append(t[k])

    if len(set(tmp)) > 1:

        print('No')

        exit()



for p in range(len(t_set)):

    tmp = []

    for q in range(len(t)):

        if t_set[p] == t[q]:

            tmp.append(s[q])

    if len(set(tmp)) > 1:

        print('No')

        exit()



print('Yes')
s = list(eval(input()))
t = list(eval(input()))
s_set = list(set(s))
t_set = list(set(t))
l = len(s)
l_s_set = len(s_set)
l_t_set = len(t_set)
x = [[] for _ in range(l)]
for i in range(l):
    x[i].append(s[i])
    x[i].append(t[i])
for j in range(l_s_set):
    tmp = []
    for k in range(l):
        if s_set[j] == x[k][0]:
            tmp.append(x[k][1])
    if len(set(tmp)) > 1:
        print("No")
        exit()
for p in range(l_t_set):
    tmp = []
    for q in range(l):
        if t_set[p] == x[q][1]:
            tmp.append(x[q][0])
    if len(set(tmp)) > 1:
        print("No")
        exit()
print("Yes")

s = list(eval(input()))
t = list(eval(input()))
s_set = list(set(s))
t_set = list(set(t))
for j in range(len(s_set)):
    tmp = []
    for k in range(len(s)):
        if s_set[j] == s[k]:
            tmp.append(t[k])
    if len(set(tmp)) > 1:
        print("No")
        exit()
for p in range(len(t_set)):
    tmp = []
    for q in range(len(t)):
        if t_set[p] == t[q]:
            tmp.append(s[q])
    if len(set(tmp)) > 1:
        print("No")
        exit()
print("Yes")

-l = len(s) -l_s_set = len(s_set) -l_t_set = len(t_set) -x = [[] for _ in range(l)] -for i in range(l): -    x[i].append(s[i]) -    x[i].append(t[i]) -for j in range(l_s_set): +for j in range(len(s_set)): -    for k in range(l): -        if s_set[j] == x[k][0]: -            tmp.append(x[k][1]) +    for k in range(len(s)): +        if s_set[j] == s[k]: +            tmp.append(t[k]) -for p in range(l_t_set): +for p in range(len(t_set)): -    for q in range(l): -        if t_set[p] == x[q][1]: -            tmp.append(x[q][0]) +    for q in range(len(t)): +        if t_set[p] == t[q]: +            tmp.append(s[q])