import random

s_given = list(eval(input()))

t_given = list(eval(input()))



s_len = len(s_given)

t_len = len(t_given)

s_sorted = sorted(s_given)

t_sorted = sorted(t_given, reverse=True)



for i in range(t_len):

    if s_sorted[i] < t_sorted[i]:

        print('Yes')

        break

    elif s_sorted[i] > t_sorted[i]:

        print('No')

        break

    if i == t_len - 1:

        print('No')

        break

    elif i == s_len - 1 :

        print('Yes')

        break

s_given = list(eval(input()))

t_given = list(eval(input()))



s_len = len(s_given)

t_len = len(t_given)

s_sorted = sorted(s_given)

t_sorted = sorted(t_given, reverse=True)



for i in range(t_len):

    if s_sorted[i] < t_sorted[i]:

        print('Yes')

        break

    elif s_sorted[i] > t_sorted[i]:

        print('No')

        break



    #s_sortedとt_sortedが同一の場合にNoと出力するため、この順序でifとelifを書く

    if i == t_len - 1:

        print('No')

        break

    elif i == s_len - 1 :

        print('Yes')

        break

import random

s_given = list(eval(input()))
t_given = list(eval(input()))
s_len = len(s_given)
t_len = len(t_given)
s_sorted = sorted(s_given)
t_sorted = sorted(t_given, reverse=True)
for i in range(t_len):
    if s_sorted[i] < t_sorted[i]:
        print("Yes")
        break
    elif s_sorted[i] > t_sorted[i]:
        print("No")
        break
    if i == t_len - 1:
        print("No")
        break
    elif i == s_len - 1:
        print("Yes")
        break

s_given = list(eval(input()))
t_given = list(eval(input()))
s_len = len(s_given)
t_len = len(t_given)
s_sorted = sorted(s_given)
t_sorted = sorted(t_given, reverse=True)
for i in range(t_len):
    if s_sorted[i] < t_sorted[i]:
        print("Yes")
        break
    elif s_sorted[i] > t_sorted[i]:
        print("No")
        break
    # s_sortedとt_sortedが同一の場合にNoと出力するため、この順序でifとelifを書く
    if i == t_len - 1:
        print("No")
        break
    elif i == s_len - 1:
        print("Yes")
        break

-import random - +    # s_sortedとt_sortedが同一の場合にNoと出力するため、この順序でifとelifを書く