s,t=eval(input()),eval(input())

rs=[""for _ in range(26)]

rt=[""for _ in range(26)]

def a(n):return [chr(ord('a')+i)for i in range(26)].index(n)

for i in range(len(s)):

  ss,tt=a(s[i]),a(t[i])

  if rs[ss]=="":rs[ss]=t[i]

  elif rs[ss]!=t[i]:print("No");exit()

  if rt[tt]=="":rt[tt]=s[i]

  elif rt[tt]!=s[i]:print("No");exit()

print("Yes")

a="abcdefghijklmnopqrstuvwxyz"

s=input()

t=input()

ds={}

dt={}

for i in a:ds[i]=dt[i]=""

for i in range(len(s)):

  if ds[s[i]]=="":ds[s[i]]=t[i]

  elif ds[s[i]]!=t[i]:exit(print("No"))

  if dt[t[i]]=="":dt[t[i]]=s[i]

  elif dt[t[i]]!=s[i]:exit(print("No"))

print("Yes")

s, t = eval(input()), eval(input())
rs = ["" for _ in range(26)]
rt = ["" for _ in range(26)]


def a(n):
    return [chr(ord("a") + i) for i in range(26)].index(n)


for i in range(len(s)):
    ss, tt = a(s[i]), a(t[i])
    if rs[ss] == "":
        rs[ss] = t[i]
    elif rs[ss] != t[i]:
        print("No")
        exit()
    if rt[tt] == "":
        rt[tt] = s[i]
    elif rt[tt] != s[i]:
        print("No")
        exit()
print("Yes")

a = "abcdefghijklmnopqrstuvwxyz"
s = input()
t = input()
ds = {}
dt = {}
for i in a:
    ds[i] = dt[i] = ""
for i in range(len(s)):
    if ds[s[i]] == "":
        ds[s[i]] = t[i]
    elif ds[s[i]] != t[i]:
        exit(print("No"))
    if dt[t[i]] == "":
        dt[t[i]] = s[i]
    elif dt[t[i]] != s[i]:
        exit(print("No"))
print("Yes")

-s, t = eval(input()), eval(input()) -rs = ["" for _ in range(26)] -rt = ["" for _ in range(26)] - - -def a(n): -    return [chr(ord("a") + i) for i in range(26)].index(n) - - +a = "abcdefghijklmnopqrstuvwxyz" +s = input() +t = input() +ds = {} +dt = {} +for i in a: +    ds[i] = dt[i] = "" -    ss, tt = a(s[i]), a(t[i]) -    if rs[ss] == "": -        rs[ss] = t[i] -    elif rs[ss] != t[i]: -        print("No") -        exit() -    if rt[tt] == "": -        rt[tt] = s[i] -    elif rt[tt] != s[i]: -        print("No") -        exit() +    if ds[s[i]] == "": +        ds[s[i]] = t[i] +    elif ds[s[i]] != t[i]: +        exit(print("No")) +    if dt[t[i]] == "": +        dt[t[i]] = s[i] +    elif dt[t[i]] != s[i]: +        exit(print("No"))