s = list(eval(input()))

s.sort()

s = "".join(s)

t = list(eval(input()))

t.sort(reverse=True)

t = "".join(t)

print(("Yes" if s < t else "No"))
s = eval(input())

s = ''.join(sorted(s))

t = eval(input())

t = ''.join(sorted(t, reverse=True))

if s < t:

    print('Yes')

else:

    print('No')



s = list(eval(input()))
s.sort()
s = "".join(s)
t = list(eval(input()))
t.sort(reverse=True)
t = "".join(t)
print(("Yes" if s < t else "No"))

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

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