s = [str(x) for x in eval(input())]

t = [str(x) for x in eval(input())]

s = sorted(s)

t = sorted(t,reverse = True)



if "".join(s) < "".join(t):

    print("Yes")

else:

    print("No")

s = sorted(eval(input()))

t = sorted(eval(input()),reverse = True)

print(("Yes" if s<t else "No"))

s = [str(x) for x in eval(input())]
t = [str(x) for x in eval(input())]
s = sorted(s)
t = sorted(t, reverse=True)
if "".join(s) < "".join(t):
    print("Yes")
else:
    print("No")

s = sorted(eval(input()))
t = sorted(eval(input()), reverse=True)
print(("Yes" if s < t else "No"))

-s = [str(x) for x in eval(input())] -t = [str(x) for x in eval(input())] -s = sorted(s) -t = sorted(t, reverse=True) -if "".join(s) < "".join(t): -    print("Yes") -else: -    print("No") +s = sorted(eval(input())) +t = sorted(eval(input()), reverse=True) +print(("Yes" if s < t else "No"))