You are given strings s and t, consisting of lowercase English letters.
You will create a string s' by freely rearranging the characters in s.
You will also create a string t' by freely rearranging the characters in t.
Determine whether it is possible to satisfy s' < t' for the lexicographic order.

-----Notes-----
For a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:
 - N < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.
 - There exists i (1 \leq i \leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.
For example, xy < xya and atcoder < atlas.

-----Constraints-----
 - The lengths of s and t are between 1 and 100 (inclusive).
 - s and t consists of lowercase English letters.

-----Input-----
Input is given from Standard Input in the following format:
s
t

-----Output-----
If it is possible to satisfy s' < t', print Yes; if it is not, print No.

-----Sample Input-----
yx
axy

-----Sample Output-----
Yes

We can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.

Difficulty: introductory

Starter code:

Solutions:
import sys

input = sys.stdin.readline
s = list(input().strip())
t = list(input().strip())
if sorted(s) < sorted(t, reverse=True):
    print("Yes")
else:
    print("No")

s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
if s<t:
  print("Yes")
else:
  print("No")
  


s = sorted(input())
t = sorted(input(), reverse=True)
s = "".join(s)
t = "".join(t)
#print(s, t)
if s<t:
    print("Yes")
else:
    print("No")

s = sorted(list(input()))
t = sorted(list(input()), reverse=True)

if s < t:
    print('Yes')
else:
    print('No')


from collections import defaultdict

s = input()
t = input()

AL = "abcdefghijklmnopqrstuvwxyz"
S = defaultdict(int)
T = defaultdict(int)

for al in s:
  S[al] += 1

for al in t:
  T[al] += 1

ans_s = ""
for al in AL:
  ans_s += al*S[al]

ans_t = ""
for al in reversed(list(AL)):
  ans_t += al*T[al]

if ans_s < ans_t:
  print("Yes")
else:
  print("No")

s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
if s<t:
    print("Yes")
else:
    print("No")


s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
print('Yes' if s < t else 'No')

s = list(input())
t = list(input())

s.sort()
t.sort(reverse = True)

s1 = ''.join(s)
t1 = ''.join(t)

if s < t :
    print("Yes")
else :
    print("No")


s = "".join(sorted(input()))
t = "".join(sorted(input(), reverse=True))
if s < t:
    print("Yes")
else:
    print("No")


s = input()
t = input()

s = "".join(sorted(s))
t = "".join(sorted(t)[::-1])

print(( "Yes" if s<t else "No"))


s=sorted(input())
t=sorted(input(),reverse=True)
if s<t:
    print("Yes")
else:
    print("No")


s = sorted(list(input()))
t = reversed(sorted(list(input())))
if ",".join(s) < ",".join(t):
    print("Yes")
else:
    print("No")

s = list(input())
t = list(input())

s = sorted(s)
t = sorted(t, reverse=True)

#print(s,t)
flag = [0,0]

if len(s) < len(t):
    for i in range(len(s)):
        if s[i]<t[i]:
            print('Yes')
            break
        elif s[i] > t[i]:
            print('No')
            break
        elif i == len(s)-1:
            print('Yes')
elif len(s) > len(t):
    for i in range(len(t)):
        if s[i]<t[i]:
            print('Yes')
            break
        elif s[i] > t[i]:
            print('No')
            break
        elif i == len(t)-1:
            print('No')
elif len(s) == len(t):
    for i in range(len(s)):
        if s[i]<t[i]:
            print('Yes')
            break
        elif s[i] > t[i]:
            print('No')
            break
        elif i == len(s)-1:
            print('No')


s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
s = "".join(s)
t = "".join(t)
print("Yes" if s < t else "No")

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


s = sorted(input())
t = sorted(input(),reverse = True)
flag1 = True
flag2 = False
if len(s) < len(t):
    for i in range(len(s)):
        if s[i] != t[i]:
            flag1 = False
            break
else:
    flag1 = False
for i in range(min(len(s), len(t))):
    if s[i] < t[i]:
        flag2 = True
        break
    elif s[i] > t[i]:
        break
if flag1 or flag2:
    print('Yes')
else:
    print('No')


s = list(map(str, input().rstrip()))
t = list(map(str, input().rstrip()))

s.sort()
t.sort(reverse=True)

s = "".join(s)
t = "".join(t)

print("Yes" if s < t else "No")

s = sorted(input())
t = sorted(input(), reverse=True)
if s < t:
  print("Yes")
else:
  print("No")

def main():
    s = input()
    t = input()
    s_list = []
    t_list = []
    for i in range(len(s)):
        s_list.append(s[i])
    for i in range(len(t)):
        t_list.append(t[i])
    s_list.sort()
    t_list.sort(reverse = True)
    #print(s_list,t_list)
    #if 'a'<'b':
        #print ('Yes')
    s_l = len(s_list)
    t_l = len(t_list)
    if s_l >= t_l:
        ans = 'No'
    else:
        ans = 'Yes'

    for i in range(min(s_l,t_l)):
        if s_list[i] == t_list[i]:
            continue
        elif s_list[i] > t_list[i]:
            return ('No')
        else:
            return('Yes')

    return ans

print((main()))


s,t = [input() for i in range(2)]

s_2 = sorted(s)
t_2 = sorted(t,reverse=True)

if s_2 < t_2:
    print("Yes")
else:
    print("No")

s = list(input())
t = list(input())
s = sorted(s)
t = sorted(t,reverse = True)
if "".join(s) < "".join(t):
  print("Yes")
else:
  print("No")

s=input()
t=input()
data=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
S=[0]*len(s)
T=[0]*len(t)
for i in range(len(s)):
  S[i]=data.index(s[i])
for i in range(len(t)):
  T[i]=data.index(t[i])
S.sort()
T.sort(reverse=True)
if S<T:
  print('Yes')
else:
  print('No')

S = input()
T = input()

if sorted(S) < sorted(T,reverse=True) :
  print("Yes")
else :
  print("No")

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


s = ''.join(sorted(list(input())))
t = ''.join(sorted(list(input()))[::-1])
print('Yes' if s < t else 'No')

s = "".join(sorted(str(input())))
t = "".join(sorted(str(input()), reverse=True))
if s < t:
    print('Yes')
else:
    print('No')

#28 B - Two Anagrams AC
s = list(input())
t = list(input())

s = sorted(s,reverse = False)
t = sorted(t,reverse = True)

s = ''.join(s)
t = ''.join(t)
if s < t:
    print('Yes')
else:
    print('No')

s,t=sorted(list(input())),sorted(list(input()),reverse=True)
print("Yes" if s<t else "No")

s = input()
t = input()

s = sorted(s)
t = sorted(t)[::-1]

answer = "Yes"
for i in range(len(s)):
  if i == len(t):
    answer = "No"
    break
  s_c = s[i]
  t_c = t[i]
  if s_c < t_c:
    break
  elif s_c == t_c:
    continue
  else:
    answer = "No"
    break

if s == t:
  answer = "No"

print(answer)

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

s = list(str(input()))
t = list(str(input()))

s.sort()
t.sort(reverse=True)

s = "".join(s)
t = "".join(t)

ans = sorted([s, t])
# print(ans)

if ans[0] == t:
    print("No")
else:
    print("Yes")


s = str(input())
t = str(input())

# 文字列sをソート（sortedをすると配列型になるのでjoinして上げる必要あり）
sort_s_list = sorted(s)
sort_s = "".join(sort_s_list)

# 文字列tを逆ソート
t_list = list(t)
t_list.sort(reverse = True)
reverse_sort_t = "".join(t_list)

if sort_s < reverse_sort_t:
    print("Yes")
else:
    print("No")

#28 B - Two Anagrams
s = list(input())
t = list(input())

s = sorted(s,reverse = False)
t = sorted(t,reverse = True)

result = 'No'
rang = min(len(s),len(t))
for i in range(rang):
    if ord(s[i]) < ord(t[i]):
        result = 'Yes'
        break
else:
    # 文字が一緒で t の方が文字数が多いとき
    if (s[:rang] == t[:rang]) and len(s) < len(t):
        result = 'Yes'
print(result)

s = sorted(str(input()))
t = sorted(str(input()), reverse = True)
print("Yes" if s < t else "No")

#n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
if s < t:
    print('Yes')
else:
    print('No')


s = list(str(input()))
t = list(str(input()))

asc_s = sorted(s)
desc_t = sorted(t, reverse=True)

print("Yes" if ''.join(asc_s) < ''.join(desc_t) else "No")

s="".join(sorted(str(input())))
t="".join(sorted(str(input()),reverse=True))
if s<t:
  print("Yes")
else:
  print("No")

s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
if s<t:print('Yes')
else:print('No')

a, b = [sorted(input()) for i in range(2)]
print("Yes" if a < b[::-1] else "No")

s = input()
t = input()

ss = sorted(s)
tt = sorted(t, reverse=True)


def checker(s, t):
    for sz in ss:
        for tz in tt:
            if sz > tz:
                return 'No'
            elif sz == tz:
                continue
            else:
                return 'Yes'
    if len(ss) < len(tt):
        return 'Yes'
    return 'No'


print((checker(ss, tt)))


s = input()
t = input()

s_list = list(s)
t_list = list(t)

s_sorted = sorted(s_list)
t_sorted = sorted(t_list, reverse=True)

s_joined = ''.join(s_sorted) 
t_joined = ''.join(t_sorted) 

if s_joined < t_joined:
    print("Yes")
else:
    print("No")

s = ''.join(sorted(input()))
t = ''.join(reversed(sorted(input())))

if s < t:
    print('Yes')
else:
    print('No')


S = sorted(input())
T = sorted(input(), reverse=True)

if S < T:
    print("Yes")
else:
    print("No")


#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

s = list(str(input()))
t = list(str(input()))

s.sort()
t.sort(reverse=True)

s = "".join(s)
t = "".join(t)

ans = sorted([s, t])
# print(ans)

if ans[0] == t:
    print("No")
else:
    print("Yes")


s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
s = ''.join(s)
t = ''.join(t)
if s < t:
  print("Yes")
else:
  print("No")

s = str(input())
t = str(input())
a = ''.join(sorted(s))
b = ''.join(sorted(t, reverse=True))
if a < b:
    print('Yes')
else:
    print('No')

s = input()
t = input()

S = "".join(sorted(list(s)))
T = "".join(sorted(list(t), reverse=True))

if S < T:
  print("Yes")
else:
  print("No")

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

S = sorted(input())
T = sorted(input(), reverse=True)

if S >= T:
    print("No")
else:
    print("Yes")

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

s = list(input())
t = list(input())

ss = sorted(s)
tt = sorted(t, reverse=True)

sa = ''.join(ss)
ta = ''.join(tt)

if sa < ta:
  print('Yes')
else:
  print('No')

list_s = sorted(list(input()))
list_t = sorted(list(input()), reverse=True)
if "".join(list_s) < "".join(list_t): print("Yes")
else: print("No")

s = list(input())
t = list(input())

s.sort(reverse=False)
t.sort(reverse=True)

if "".join(s) < "".join(t):
  print("Yes")
else:
  print("No")

s, t = [input() for i in range(2)]
ns = ''.join(sorted(s))
nt = ''.join(sorted(t, reverse=True))
print('Yes') if ns < nt else print('No')


s=sorted(list(input()))
t=sorted(list(input()),reverse=True)
for i in range(min(len(s),len(t))):
    if ord(s[i])<ord(t[i]):
        print("Yes")
        return
    elif ord(s[i])>ord(t[i]):
        print("No")
        return
if len(s)>=len(t):
    print("No")
else:
    print("Yes")

s = sorted(input())
t = sorted(input(),reverse=True)
if(s < t): print("Yes")
else: print("No")

s = input()
t = input()
S = sorted(s)
T = sorted(t,reverse=True)
#print(S,T)
ans = "W"
for i in range(min(len(s),len(t))):
    if S[i] > T[i]:
        ans = "No"
        break
    elif ans == "W" and S[i] == T[i]:
        ans = "W"
    elif ans == "W" and S[i] < T[i]:
        ans = "Yes"
        break
if ans == "W":
    if len(s) < len(t):
        ans = "Yes"
    else:
        ans = "No"
print(ans)

ss, ts = sorted(list(input())), list(reversed(sorted(list(input()))))
result = False
min_size = min(len(ss), len(ts))

if ss[:min_size] == ts[:min_size] and len(ss) < len(ts):
    result = True
else:
    for index in range(min(len(ss), len(ts))):
        if ss[index] < ts[index]:
            result = True
            break

if result:
    print("Yes")
else:
    print("No")


s = sorted(list(input()))
t = sorted(list(input()),reverse=True)
if s<t:
    print('Yes')
else:
    print('No')

s=input()
t=input()

s_d = ''.join(sorted(s))
t_d = ''.join(sorted(t,reverse=True))

arr = [t_d,s_d]
arr=sorted(arr)

if s==t:
    print('No')
    return

if arr[0]==s_d:
    print('Yes')
else:
    print('No')

s = str(input())
t = str(input())

num2alpha = lambda c: chr(c+96)
#print(num2alpha(3)) #==> c
alpha2num = lambda c: ord(c) - ord('a') + 1
#alpha2num('y') #==> 25 

S = [0] * 26
T = [0] * 26
for i in range(len(s)):
  S[alpha2num(s[i]) - 1] += 1
for i in range(len(t)):
  T[alpha2num(t[i]) - 1] += 1
#print(S, T)  
  
ss = 0
while S[ss] == 0:
  ss += 1
tt = 25
while T[tt] == 0:
  tt -= 1
  
if tt < ss:
  print("No")
elif tt > ss:
  print("Yes")
else:
  if (T[tt] == sum(T)) and (S[ss] == sum(S)):
    if sum(T) > sum(S):
      print("Yes")
    else:
      print("No")
  else:
    print("No")
  
  
  

  


s = sorted(input())
t = sorted(input(),reverse = True)
if s < t:
    print('Yes')
else:
    print('No')

# -*- coding: utf-8 -*-

s = list(input())
t = list(input())

N = len(s)
M = len(t)

s_d = sorted(s)
t_d = sorted(t, reverse=True)

ans ='No'
if N < M:
    new_t = "".join(t_d[:N])
    new_s = "".join(s_d)
    if new_t == new_s:
        ans ='Yes'

if ans == 'No':
    pos = 0
    for i in range(min(N, M)):
        if s_d[i]!=t_d[i]:
            pos = i
            break
    if s_d[pos] < t_d[pos]:
        ans ='Yes'

print(ans)

s = input()
t = input()

sorted_s = sorted(s)
sorted_t = sorted(t, reverse=True)

#print(sorted_s)
#print(sorted_t)

if sorted_s < sorted_t:
    print("Yes")
else:
    print("No")



S = list(input())
T = list(input())

S.sort()
T.sort(reverse=True)

alpha = list('abcdefghijklmnopqrstuvwxyz')

check = False
cnt = 0
for s, t in zip(S,T):
  res = alpha.index(s) - alpha.index(t)
  if res < 0:
    check = True
    break
  elif res == 0:
    cnt += 1

if cnt == len(S):
  if len(S) < len(T):
    check = True

print("Yes" if check else "No")

s = list(input())
t = list(input())
s.sort()
t.sort(reverse = True)
if s < t:
    print('Yes')
else:
    print('No')

s = input()
t = input()

s = list(s)
t = list(t)
s.sort()
t.sort(reverse=True)

s = "".join(s)
t = "".join(t)

print("Yes") if s < t else print("No")

s = list(input())
t = list(input())

s.sort()
t.sort(reverse=True)

s = ''.join(s)
t = ''.join(t)

if s < t:
    print('Yes')
else:
    print('No')


S = input()
T = input()
S_len = len(S)
T_len = len(T)
S_sorted = sorted(S)
T_sorted = sorted(T, reverse=True)
ans = True
for i in range(min(S_len, T_len)):
    s = ord(S_sorted[i])
    t = ord(T_sorted[i])
    if s < t:
        print('Yes')
        return
    if s == t:
        continue
    else:
        print('No')
        return
if S_len >= T_len:
    print('No')
else:
    print('Yes')


s = input()
t = input()
s = sorted(s)
t = sorted(t, reverse=True)
s_t = [s, t]
s_t.sort()
if s_t[0] == s and s_t[1] != s:
    print("Yes")
else:
    print("No")


s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)

l = [''.join(s),''.join(t)]

if l == sorted(l) and l[0]!=l[1]:
    print('Yes')
else:
    print('No')

s = input()
s_asc = ''.join(sorted(s))
t = input()
t_desc = ''.join(sorted(t, reverse=True))
if s_asc < t_desc:
	print('Yes')
else:
	print('No')

s = input()
t = input()

if "".join(sorted(s)) < "".join(list(reversed(sorted(t)))):
    print("Yes")
else:
    print("No")


s = input()
t = input()

if "".join(sorted(s)) < "".join(sorted(t, reverse=True)):
    print("Yes")
else:
    print("No")


a = list(input())
b = list(input())
a.sort()
b.sort()
b.reverse()
a=''.join(a)
b=''.join(b)
if a < b:
    print("Yes")
else:
    print("No")

s = sorted(x for x in input())
t = sorted([x for x in input()], reverse=True)
print('Yes' if s < t else 'No')

def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  S=input()
  T=input()
  if S==T:
    print("No")
    return
  if S in T:
    print("Yes")
    return
  s=list(S)
  t=list(T)
  
  s.sort()
  t.sort(reverse=True)
  if s==t:
    print("No")
    return
  
#  if(len(s)<len(t)):
#    print("Yes")
#    return
  for i in range(min(len(s),len(t))):
    if ord(s[i])>ord(t[i]):
      print("No")
      return
    elif ord(s[i])<ord(t[i]):
      print("Yes")
      return
  print("No")
  return
main()

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

#!/usr/bin/env python3


def main():
    s = sorted(input())
    t = sorted(input(), reverse=True)
    if s < t:
        print("Yes")
    else:
        print("No")


main()


#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    s = input()
    t = input()

    listS = []
    for i in range(len(s)):
        listS.append(s[i])

    listT = []
    for i in range(len(t)):
        listT.append(t[i])

    listS = sorted(listS)
    listT = sorted(listT, reverse=True)

    sortedS = ''
    for i in range(len(listS)):
        sortedS += listS[i]
    sortedT = ''
    for i in range(len(listT)):
        sortedT += listT[i]

    if sortedS < sortedT:
        print('Yes')
    else:
        print('No')

def __starting_point():
    main()

__starting_point()

s,t=sorted(list(input())),sorted(list(input()),reverse=True)
print("Yes" if s<t else "No")

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

s = input().rstrip()
t = input().rstrip()

s = tuple(sorted(s))
t = tuple(sorted(t, reverse=True))
if s < t:
    print('Yes')
else:
    print('No')

s = sorted(input())
t = sorted(input(),reverse = True)
if s < t:
    print('Yes')
else:
    print('No')

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

s = input()
t = input()
if ''.join(sorted(s)) < ''.join(sorted(t, reverse=True)):
    print('Yes')
else :
    print('No')

s = list(input())
t = list(input())

s.sort()
t.sort(reverse = True)

if s < t:
    print('Yes')
else:
    print('No')

s = sorted(input())
t = sorted(input(), reverse=True)
print('Yes' if s < t else 'No')

def answer(s: str, t: str) -> str:
    return 'Yes' if sorted(s) < sorted(t, reverse=True) else 'No'

def main():
    s = input()
    t = input()
    print(answer(s,t))

def __starting_point():
    main()
__starting_point()

s = input()
t = input()
import sys
if s==t:
    print("No")
    return
ss = sorted(list(s))
tt = sorted(list(t))[::-1]
if sorted([ss,tt])[0] == ss:
    print("Yes")
else:
    print("No")

s = list(input())
t = list(input())

s.sort()
t.sort(reverse = True)

for i in range(min(len(s), len(t))):
    if s[i] < t[i]:
        print('Yes')
        break
    elif s[i] > t[i]:
        print('No')
        break
    else:
        continue
else:
    if len(t) > len(s):
        print('Yes')
    else:
        print('No')

s=list(input())
t=list(input())

s.sort()
t.sort(reverse=True)

for i in range(min(len(s),len(t))):
    if(s[i]<t[i]):
        print("Yes")
        return
    if(s[i]>t[i]):
        print("No")
        return

if(len(s)<len(t)):
    print("Yes")
else:
    print("No")


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

print('Yes' if s<t else 'No')

s = input()
t = input()
 
sp = sorted(s)
tp = sorted(t, reverse=True)
#print(sp, tp)
print(('Yes' if sp < tp else 'No'))


s, t = sorted(input()), sorted(input())[::-1]

if "".join(s) < "".join(t):
    print("Yes")
else:
    print("No")

S = sorted(input())
T = sorted(input())[::-1]
print('Yes' if S < T else 'No')

s = input()
t = input()
ord_s = []
ord_t = []

for i in range(len(s)):
  ord_s.append(ord(s[i]))
else:
  ord_s.sort()
  
for i in range(len(t)):
  ord_t.append(ord(t[i]))
else:
  ord_t.sort(reverse = True)

for i in range(min(len(s), len(t))):
  if ord_s[i] < ord_t[i]:
    print('Yes')
    break
  elif ord_s[i] == ord_t[i]:
    pass
  else:
    print('No')
    break
else:
  if len(s) < len(t):
    print('Yes')
  else:
    print('No')

s,t=[input() for i in range(2)]
print('Yes' if sorted(s)<sorted(t,reverse=True) else 'No')

import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    s = ins()
    t = ins()
    s = sorted(s)
    t = sorted(t, reverse=True)
    return s < t


print("Yes" if solve() else "No")


s = input()
t = input()
if s < t:
    print("Yes")
    return
s = list(s)
t = list(t)
s = sorted(s)
t = sorted(t)
t = t[::-1]
s = ''.join(s)
t = ''.join(t)
if s < t:
    print("Yes")
else:
    print("No")