S = input().strip()

T = input().strip()

F = {}

flag = 0

for i in range(len(S)):

    a = S[i]

    b = T[i]

    if a not in F:

        F[a] = b

    if F[a] != b:

        flag = 1

        break

    for c in F:

        if c!=a and F[c]==b:

            flag = 1

            break

if flag==1:

    print("No")

else:

    print("Yes")

A = {chr(i):0 for i in range(97,123)}

S = input().strip()

T = input().strip()

N = len(S)

G = {}

for i in range(N):

    a = S[i]

    if a not in G:

        G[a]=[]

    b = T[i]

    if b not in G[a]:

        G[a].append(b)

flag = 0

cnt = 0

for a in G:

    cnt += 1

    if len(G[a])>1:

        flag = 1

        break

    if len(G[a])==0 and cnt==26:

        break

    b = G[a][0]

    if a!=b:

        cnt += 1

    if A[b]==0:

        A[b] += 1

    else:

        flag = 1

        break

if flag==1:

    print("No")

else:

    print("Yes")
S = input().strip()
T = input().strip()
F = {}
flag = 0
for i in range(len(S)):
    a = S[i]
    b = T[i]
    if a not in F:
        F[a] = b
    if F[a] != b:
        flag = 1
        break
    for c in F:
        if c != a and F[c] == b:
            flag = 1
            break
if flag == 1:
    print("No")
else:
    print("Yes")

A = {chr(i): 0 for i in range(97, 123)}
S = input().strip()
T = input().strip()
N = len(S)
G = {}
for i in range(N):
    a = S[i]
    if a not in G:
        G[a] = []
    b = T[i]
    if b not in G[a]:
        G[a].append(b)
flag = 0
cnt = 0
for a in G:
    cnt += 1
    if len(G[a]) > 1:
        flag = 1
        break
    if len(G[a]) == 0 and cnt == 26:
        break
    b = G[a][0]
    if a != b:
        cnt += 1
    if A[b] == 0:
        A[b] += 1
    else:
        flag = 1
        break
if flag == 1:
    print("No")
else:
    print("Yes")

+A = {chr(i): 0 for i in range(97, 123)} -F = {} +N = len(S) +G = {} +for i in range(N): +    a = S[i] +    if a not in G: +        G[a] = [] +    b = T[i] +    if b not in G[a]: +        G[a].append(b) -for i in range(len(S)): -    a = S[i] -    b = T[i] -    if a not in F: -        F[a] = b -    if F[a] != b: +cnt = 0 +for a in G: +    cnt += 1 +    if len(G[a]) > 1: -    for c in F: -        if c != a and F[c] == b: -            flag = 1 -            break +    if len(G[a]) == 0 and cnt == 26: +        break +    b = G[a][0] +    if a != b: +        cnt += 1 +    if A[b] == 0: +        A[b] += 1 +    else: +        flag = 1 +        break