# coding: utf-8

s = eval(input())

t = eval(input())

re_s = sorted(s)

re_t = sorted(t, reverse=True)

print(("Yes" if re_s < re_t else "No"))
# coding: utf-8

s = list(eval(input()))

t = list(eval(input()))

s.sort()

t.sort(reverse=True)

sd = "".join(s)

td = "".join(t)

print(("Yes" if sd < td else "No"))
# coding: utf-8
s = eval(input())
t = eval(input())
re_s = sorted(s)
re_t = sorted(t, reverse=True)
print(("Yes" if re_s < re_t else "No"))

# coding: utf-8
s = list(eval(input()))
t = list(eval(input()))
s.sort()
t.sort(reverse=True)
sd = "".join(s)
td = "".join(t)
print(("Yes" if sd < td else "No"))

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