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()

N = len(S)

C = {}

D = {}

flag = 0

for i in range(N):

    if S[i] not in C:

        C[S[i]] = T[i]

    elif C[S[i]]!=T[i]:

        flag = 1

        break

    if T[i] not in D:

        D[T[i]] = S[i]

    elif D[T[i]] != S[i]:

        flag = 1

        break

if flag==0:

    print("Yes")

else:

    print("No")
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()
N = len(S)
C = {}
D = {}
flag = 0
for i in range(N):
    if S[i] not in C:
        C[S[i]] = T[i]
    elif C[S[i]] != T[i]:
        flag = 1
        break
    if T[i] not in D:
        D[T[i]] = S[i]
    elif D[T[i]] != S[i]:
        flag = 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")

-A = {chr(i): 0 for i in range(97, 123)} -G = {} +C = {} +D = {} +flag = 0 -    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: +    if S[i] not in C: +        C[S[i]] = T[i] +    elif C[S[i]] != T[i]: -    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: +    if T[i] not in D: +        D[T[i]] = S[i] +    elif D[T[i]] != S[i]: -if flag == 1: +if flag == 0: +    print("Yes") +else: -else: -    print("Yes")