from collections import defaultdict



s = eval(input())

t = eval(input())



AL = "abcdefghijklmnopqrstuvwxyz"

S = defaultdict(int)

T = defaultdict(int)



for al in s:

  S[al] += 1



for al in t:

  T[al] += 1



ans_s = ""

for al in AL:

  ans_s += al*S[al]



ans_t = ""

for al in reversed(list(AL)):

  ans_t += al*T[al]



if ans_s < ans_t:

  print("Yes")

else:

  print("No")
s = eval(input())

t = eval(input())



S = "".join(sorted(list(s)))

T = "".join(sorted(list(t), reverse=True))



if S < T:

  print("Yes")

else:

  print("No")
from collections import defaultdict

s = eval(input())
t = eval(input())
AL = "abcdefghijklmnopqrstuvwxyz"
S = defaultdict(int)
T = defaultdict(int)
for al in s:
    S[al] += 1
for al in t:
    T[al] += 1
ans_s = ""
for al in AL:
    ans_s += al * S[al]
ans_t = ""
for al in reversed(list(AL)):
    ans_t += al * T[al]
if ans_s < ans_t:
    print("Yes")
else:
    print("No")

s = eval(input())
t = eval(input())
S = "".join(sorted(list(s)))
T = "".join(sorted(list(t), reverse=True))
if S < T:
    print("Yes")
else:
    print("No")

-from collections import defaultdict - -AL = "abcdefghijklmnopqrstuvwxyz" -S = defaultdict(int) -T = defaultdict(int) -for al in s: -    S[al] += 1 -for al in t: -    T[al] += 1 -ans_s = "" -for al in AL: -    ans_s += al * S[al] -ans_t = "" -for al in reversed(list(AL)): -    ans_t += al * T[al] -if ans_s < ans_t: +S = "".join(sorted(list(s))) +T = "".join(sorted(list(t), reverse=True)) +if S < T: