s = eval(input())

t = eval(input())

s_dash = []

t_dash = []

s_d = ""

t_d = ""

for i in range(len(s)):

  s_dash.append(s[i])

for j in range(len(t)):

  t_dash.append(t[j])

s_dash.sort()

t_dash.sort()

t_dash.reverse()

for i in range(len(s_dash)):

  s_d += s_dash[i]

for j in range(len(t_dash)):

  t_d += t_dash[j]

if s_d<t_d:

  print("Yes")

else:

  print("No")
s = list(eval(input()))

t = list(eval(input()))

s.sort()

t.sort()

t.reverse()

A = ''.join(s)

B = ''.join(t)

if s<t:

  print("Yes")

else:

  print("No")
s = eval(input())
t = eval(input())
s_dash = []
t_dash = []
s_d = ""
t_d = ""
for i in range(len(s)):
    s_dash.append(s[i])
for j in range(len(t)):
    t_dash.append(t[j])
s_dash.sort()
t_dash.sort()
t_dash.reverse()
for i in range(len(s_dash)):
    s_d += s_dash[i]
for j in range(len(t_dash)):
    t_d += t_dash[j]
if s_d < t_d:
    print("Yes")
else:
    print("No")

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

-s = eval(input()) -t = eval(input()) -s_dash = [] -t_dash = [] -s_d = "" -t_d = "" -for i in range(len(s)): -    s_dash.append(s[i]) -for j in range(len(t)): -    t_dash.append(t[j]) -s_dash.sort() -t_dash.sort() -t_dash.reverse() -for i in range(len(s_dash)): -    s_d += s_dash[i] -for j in range(len(t_dash)): -    t_d += t_dash[j] -if s_d < t_d: +s = list(eval(input())) +t = list(eval(input())) +s.sort() +t.sort() +t.reverse() +A = "".join(s) +B = "".join(t) +if s < t: