s = str(eval(input()))

t = str(eval(input()))



S = [0]*26

T = [0]*26

for i in range(len(s)):

    c = ord(s[i])-ord('a')

    S[c] += 1



for i in range(len(t)):

    c = ord(t[i])-ord('a')

    T[c] += 1



s_ = ''

for i in range(26):

    s_ += chr(i+ord('a'))*S[i]



t_ = ''

for i in reversed(list(range(26))):

    t_ += chr(i+ord('a'))*T[i]



X = [s_, t_]

#print(X)

if s_ == t_:

    print('No')

    exit()

Y = sorted(X)

if X[0] == Y[0]:

    print('Yes')

else:

    print('No')

s = str(eval(input()))

t = str(eval(input()))



s_ = list(s)

s_.sort()

s_ = ''.join(s_)



t_ = list(t)

t_.sort(reverse= True)

t_ = ''.join(t_)



if s_ == t_:

    print('No')

    exit()



L = [(s_, 0), (t_, 1)]

L.sort()

#print(L)

if L[0][1] == 0:

    print('Yes')

else:

    print('No')

s = str(eval(input()))
t = str(eval(input()))
S = [0] * 26
T = [0] * 26
for i in range(len(s)):
    c = ord(s[i]) - ord("a")
    S[c] += 1
for i in range(len(t)):
    c = ord(t[i]) - ord("a")
    T[c] += 1
s_ = ""
for i in range(26):
    s_ += chr(i + ord("a")) * S[i]
t_ = ""
for i in reversed(list(range(26))):
    t_ += chr(i + ord("a")) * T[i]
X = [s_, t_]
# print(X)
if s_ == t_:
    print("No")
    exit()
Y = sorted(X)
if X[0] == Y[0]:
    print("Yes")
else:
    print("No")

s = str(eval(input()))
t = str(eval(input()))
s_ = list(s)
s_.sort()
s_ = "".join(s_)
t_ = list(t)
t_.sort(reverse=True)
t_ = "".join(t_)
if s_ == t_:
    print("No")
    exit()
L = [(s_, 0), (t_, 1)]
L.sort()
# print(L)
if L[0][1] == 0:
    print("Yes")
else:
    print("No")

-S = [0] * 26 -T = [0] * 26 -for i in range(len(s)): -    c = ord(s[i]) - ord("a") -    S[c] += 1 -for i in range(len(t)): -    c = ord(t[i]) - ord("a") -    T[c] += 1 -s_ = "" -for i in range(26): -    s_ += chr(i + ord("a")) * S[i] -t_ = "" -for i in reversed(list(range(26))): -    t_ += chr(i + ord("a")) * T[i] -X = [s_, t_] -# print(X) +s_ = list(s) +s_.sort() +s_ = "".join(s_) +t_ = list(t) +t_.sort(reverse=True) +t_ = "".join(t_) -Y = sorted(X) -if X[0] == Y[0]: +L = [(s_, 0), (t_, 1)] +L.sort() +# print(L) +if L[0][1] == 0: