from collections import*;C=Counter;i=lambda:C(list(C(eval(input())).values()));print(('YNeos'[i()!=i()::2]))
s,t=[sorted(x.count(i)for i in set(x)) for x in open(0)]

print(('YNeos'[s!=t::2]))
from collections import *

C = Counter
i = lambda: C(list(C(eval(input())).values()))
print(("YNeos"[i() != i() :: 2]))

s, t = [sorted(x.count(i) for i in set(x)) for x in open(0)]
print(("YNeos"[s != t :: 2]))

-from collections import * - -C = Counter -i = lambda: C(list(C(eval(input())).values())) -print(("YNeos"[i() != i() :: 2])) +s, t = [sorted(x.count(i) for i in set(x)) for x in open(0)] +print(("YNeos"[s != t :: 2]))