S = eval(input())

T = eval(input())

assert len(S) == len(T)



def normalized(S):

    dic = {}  # char -> occurence order

    last = -1

    T = []

    for s in S:

        if s not in dic:

            last += 1

            dic[s] = last

        T.append(dic[s])

    return T



print(("Yes" if normalized(S) == normalized(T) else "No"))
S = eval(input())

T = eval(input())

assert len(S) == len(T)



def uniq(s):

    '''Return the list obtained from s by removing repeating chars.'''

    appeared = set()

    for c in s:

        if c not in appeared:

            appeared.add(c)

            yield c



def normalized(s):

    dic = {c: i for i, c in enumerate(uniq(s))}

    return [dic[c] for c in s]



print(("Yes" if normalized(S) == normalized(T) else "No"))
S = eval(input())
T = eval(input())
assert len(S) == len(T)


def normalized(S):
    dic = {}  # char -> occurence order
    last = -1
    T = []
    for s in S:
        if s not in dic:
            last += 1
            dic[s] = last
        T.append(dic[s])
    return T


print(("Yes" if normalized(S) == normalized(T) else "No"))

S = eval(input())
T = eval(input())
assert len(S) == len(T)


def uniq(s):
    """Return the list obtained from s by removing repeating chars."""
    appeared = set()
    for c in s:
        if c not in appeared:
            appeared.add(c)
            yield c


def normalized(s):
    dic = {c: i for i, c in enumerate(uniq(s))}
    return [dic[c] for c in s]


print(("Yes" if normalized(S) == normalized(T) else "No"))

-def normalized(S): -    dic = {}  # char -> occurence order -    last = -1 -    T = [] -    for s in S: -        if s not in dic: -            last += 1 -            dic[s] = last -        T.append(dic[s]) -    return T +def uniq(s): +    """Return the list obtained from s by removing repeating chars.""" +    appeared = set() +    for c in s: +        if c not in appeared: +            appeared.add(c) +            yield c + + +def normalized(s): +    dic = {c: i for i, c in enumerate(uniq(s))} +    return [dic[c] for c in s]