s=sorted(eval(input()))

t=sorted(eval(input()))[::-1]

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

t=eval(input())

print(("Yes" if sorted(s)<sorted(t)[::-1] else "No"))
s = sorted(eval(input()))
t = sorted(eval(input()))[::-1]
print(("Yes" if s < t else "No"))

s = eval(input())
t = eval(input())
print(("Yes" if sorted(s) < sorted(t)[::-1] else "No"))

-s = sorted(eval(input())) -t = sorted(eval(input()))[::-1] -print(("Yes" if s < t else "No")) +s = eval(input()) +t = eval(input()) +print(("Yes" if sorted(s) < sorted(t)[::-1] else "No"))