s=sorted(eval(input()))

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



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

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

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