s=eval(input());d=eval(input());n=len(s)

di={"abcdefghijklmnopqrstuvwxyz"[i]:i for i in range(26)}

sl,dl=[set() for _ in range(26)],[set() for _ in range(26)]

for i,(x,y) in enumerate(zip(s,d)):

  sl[di[x]].add(i);dl[di[y]].add(i)

for i in dl:

  if i and i not in sl :print("No");exit() 

print("Yes")

s=eval(input());d=eval(input())

l=('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z')

for a,c in zip(sorted([s.count(i)for i in l]),sorted([d.count(i)for i in l])):

  if a!=c:print("No");exit()

print("Yes")
s = eval(input())
d = eval(input())
n = len(s)
di = {"abcdefghijklmnopqrstuvwxyz"[i]: i for i in range(26)}
sl, dl = [set() for _ in range(26)], [set() for _ in range(26)]
for i, (x, y) in enumerate(zip(s, d)):
    sl[di[x]].add(i)
    dl[di[y]].add(i)
for i in dl:
    if i and i not in sl:
        print("No")
        exit()
print("Yes")

s = eval(input())
d = eval(input())
l = (
    "a",
    "b",
    "c",
    "d",
    "e",
    "f",
    "g",
    "h",
    "i",
    "j",
    "k",
    "l",
    "m",
    "n",
    "o",
    "p",
    "q",
    "r",
    "s",
    "t",
    "u",
    "v",
    "w",
    "x",
    "y",
    "z",
)
for a, c in zip(sorted([s.count(i) for i in l]), sorted([d.count(i) for i in l])):
    if a != c:
        print("No")
        exit()
print("Yes")

-n = len(s) -di = {"abcdefghijklmnopqrstuvwxyz"[i]: i for i in range(26)} -sl, dl = [set() for _ in range(26)], [set() for _ in range(26)] -for i, (x, y) in enumerate(zip(s, d)): -    sl[di[x]].add(i) -    dl[di[y]].add(i) -for i in dl: -    if i and i not in sl: +l = ( +    "a", +    "b", +    "c", +    "d", +    "e", +    "f", +    "g", +    "h", +    "i", +    "j", +    "k", +    "l", +    "m", +    "n", +    "o", +    "p", +    "q", +    "r", +    "s", +    "t", +    "u", +    "v", +    "w", +    "x", +    "y", +    "z", +) +for a, c in zip(sorted([s.count(i) for i in l]), sorted([d.count(i) for i in l])): +    if a != c: