s = eval(input())

t = eval(input())



ans = {c:[] for c in 'abcdefghijklmnopqrstuvwxyz'}

res = {c:[] for c in 'abcdefghijklmnopqrstuvwxyz'}

cnt = 0

for a,b in zip(s,t):

    ans[b].append(a)

    res[a].append(b)

    # elif ans[a] != a and ans[ans[a]] != ans[b]:

    #     print(a, b, '0', a, b, ans[a],  ans[b], cnt)

    #     print('No')

    #     break

    cnt += 1



aa = [0 for v in list(ans.values()) if len(set(v)) > 1]

bb = [0 for v in list(res.values()) if len(set(v)) > 1]



if len(aa) == 0 and len(bb) == 0:

    print('Yes')

else:

    print('No')

# print(ans)

s = eval(input())

t = eval(input())



ans = {c:[] for c in 'abcdefghijklmnopqrstuvwxyz'}

res = {c:[] for c in 'abcdefghijklmnopqrstuvwxyz'}

for a,b in zip(s,t):

    ans[b].append(a)

    res[a].append(b)



aa = [0 for v in list(ans.values()) if len(set(v)) > 1]

bb = [0 for v in list(res.values()) if len(set(v)) > 1]



if len(aa) == 0 and len(bb) == 0:

    print('Yes')

else:

    print('No')

s = eval(input())
t = eval(input())
ans = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
res = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
cnt = 0
for a, b in zip(s, t):
    ans[b].append(a)
    res[a].append(b)
    # elif ans[a] != a and ans[ans[a]] != ans[b]:
    #     print(a, b, '0', a, b, ans[a],  ans[b], cnt)
    #     print('No')
    #     break
    cnt += 1
aa = [0 for v in list(ans.values()) if len(set(v)) > 1]
bb = [0 for v in list(res.values()) if len(set(v)) > 1]
if len(aa) == 0 and len(bb) == 0:
    print("Yes")
else:
    print("No")
# print(ans)

s = eval(input())
t = eval(input())
ans = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
res = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
for a, b in zip(s, t):
    ans[b].append(a)
    res[a].append(b)
aa = [0 for v in list(ans.values()) if len(set(v)) > 1]
bb = [0 for v in list(res.values()) if len(set(v)) > 1]
if len(aa) == 0 and len(bb) == 0:
    print("Yes")
else:
    print("No")

-cnt = 0 -    # elif ans[a] != a and ans[ans[a]] != ans[b]: -    #     print(a, b, '0', a, b, ans[a],  ans[b], cnt) -    #     print('No') -    #     break -    cnt += 1 -# print(ans)