Problem:
 Score : 200 points    Problem Statement 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 1 yx
axy      Sample Output 1 Yes  We can, for example, rearrange yx into xy and axy into yxa . Then, xy  <  yxa .       Sample Input 2 ratcode
atlas      Sample Output 2 Yes  We can, for example, rearrange ratcode into acdeort and atlas into tslaa . Then, acdeort  <  tslaa .       Sample Input 3 cd
abc      Sample Output 3 No  No matter how we rearrange cd and abc , we cannot achieve our objective.       Sample Input 4 w
ww      Sample Output 4 Yes       Sample Input 5 zzz
zzz      Sample Output 5 No

Solution (Python):
from sys import stdin
s = "".join(sorted(list(stdin.readline().rstrip())))
t = "".join(reversed((sorted(list(stdin.readline().rstrip())))))
if s < t:
    print("Yes")
else:
    print("No")

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

Solution (Python):
s = input()
t = input()

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

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

Solution (Python):
s = input()
t = input()

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

Solution (Python):
s = input()
t = input()

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

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

Solution (Python):
s = sorted(input())
t = sorted(input())

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

Solution (Python):
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")

Solution (Python):
s = list(input())
t = list(input())
a = 0

s.sort()
t.sort()
t = t[::-1]

if len(s) < len(t):
    for i in range(len(s)):
        if s[i] < t[i]:
            print("Yes")
            break
        elif s[i] == t[i]:
            a += 1
            continue
        else:
            print("No")
            break
    if a == len(s):
        print("Yes")

else:
    for i in range(len(t)):
        if s[i] < t[i]:
            print("Yes")
            break
        elif s[i] == t[i]:
            a += 1
            continue
        else:
            print("No")
            break
    if a == len(t):
        print("No")

Solution (Python):
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')

Solution (Python):

from functools import reduce 

ss = input()
st = input()


ls = [c for c in ss]
lt = [c for c in st]




ls.sort()
lt.sort(reverse = True)

ans_s = reduce( lambda x,y: x+y, ls,'' )
ans_t = reduce(lambda x, y: x+y, lt)




print( 'Yes' if ans_s < ans_t else 'No' )

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

Solution (Python):
rs = ''.join(sorted(list(input())))
rt = ''.join(sorted(list(input()),reverse=True))
print('Yes' if rs<rt else 'No')

Solution (Python):
a=list(input())
b=list(input())
a.sort()
b.sort(reverse=True)
print(["No","Yes"]["".join(a)<"".join(b)])

Solution (Python):

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


s.sort()
s=''.join(s)


t.sort()
t.reverse()
t=''.join(t)


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

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    

    
    

    
    
    
    
    
    
    
    
    
    INF = float("inf")

    
    MOD = 10**9+7
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    s = list(_ for _ in input())
    t = list(_ for _ in input())
    s.sort()
    t.sort()
    t=t[::-1]
    if ''.join(s) <''.join(t):        
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

Solution (Python):
s = [i for i in input()]
t = [j for j in input()]
s.sort()
t.sort(reverse=True)
flag = False

for i in range(min(len(s), len(t))):
  if s[i] < t[i]:
    print("Yes")
    flag = True
    break
  else:
    pass
  
if flag:
  pass
else:
  if len(s) < len(t) and len(set(s)) == len(set(t)):
    print("Yes")
  else:
    print("No")

Solution (Python):
import itertools
import math
s1 = input()
s1 = list(s1)
s1.sort()
s1 ="".join(s1)
s2 = input()
s2 = list(s2)
s2.sort(reverse=True)
s2 ="".join(s2)
if s1 < s2:
    print("Yes")
else:
    print("No")

Solution (Python):
s=sorted(input())
t=sorted(input(),reverse=True)

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    return


def B():
    s = S()
    t = S()
    s.sort()
    t.sort(reverse = True)
    if s < t:
        print("Yes")
    else:
        print("No")
    return


def C():
    n = I()
    d = [None for i in range(n+1)]
    d[0] = 2
    d[1] = 1
    for i in range(2,n+1):
        d[i] = d[i-1]+d[i-2]
    print(d[n])
    return


def D():
    x,y,z = LI()
    for i in range(1000000)[::-1]:
        if i*y+(i+1)*z <= x:
            print(i)
            quit()
    return


def E():
    d = [(1,0),(-1,0),(0,1),(0,-1)]
    h,w = LI()
    s = SR(h)
    for i in range(h):
        for j in range(w):
            if s[i][j] == "
                su = 0
                for dy,dx in d:
                    y = i+dy
                    x = j+dx
                    if 0 <= y < h and 0 <= x < w:
                        if s[y][x] == "
                            su += 1
                if su == 0:
                    print("No")
                    quit()
    print("Yes")
    return


def F():
    a,b,c,X,Y = LI()
    ans = float("inf")
    for z in range(300001):
        if z%2 == 0:
            m = c*z
            x = z//2
            y = z//2
            m += a*max(0,X-x)
            m += b*max(0,Y-y)
            if m < ans:
                ans = m
    print(ans)
    return


def G():
    n = I()
    x = LI()
    f = [(i,x[i]) for i in range(n)]
    f.sort(key = lambda x:x[1])
    g = [(f[i][0],i) for i in range(n)]
    g.sort(key = lambda x:x[0])
    for i in range(n):
        if g[i][1] < n//2:
            print(f[n//2][1])
        else:
            print(f[n//2-1][1])
    return


def H():
    return


def I_():
    return


def J():
    return


if __name__ == "__main__":
    B()

Solution (Python):
s = [i for i in input()]
t = [i for i in input()]
s.sort()
t.sort(reverse = True)
print("Yes" if "".join(s) < "".join(t) else "No")

Solution (Python):


import math

alpha = 'abcdefghijklmnopqrstuvwxyz'

s = input()
t = input()

if s in t and s != t:
    print('Yes')
    exit()
if s == t:
    print('No')
    exit()
if t in s and s != t:
    print('No')

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


for i in range(min(len(s),len(t))):
    for k in range(26):
        if s[i] == alpha[k]:
            x = k
        if t[i] == alpha[k]:
            y = k
    
    if x < y:
        print('Yes')
        exit()
    if y < x:
        print('No')
        exit()

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

Solution (Python):
s = input()
t = input()

ss = ''.join(sorted(s))
tt = ''.join(sorted(t, reverse=True))

if ss < tt:
    print('Yes')
else:
    print('No')

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

Solution (Python):
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]:
        count=1
        continue
    elif s[i]<t[i]:
        count=2
        break
    else:
        count=0
        break
if count==1:
    if len(s)<len(t):
        print('Yes')
    else:
        print('No')
elif count==2:
    print('Yes')
else:
    print('No')

Solution (Python):
s=[x for x in input()]
t=[x for x in input()]
s.sort()
t.sort()
t = t[::-1]
s=''.join(s)
t=''.join(t)
print('Yes' if s<t else 'No')

Solution (Python):
S = sorted([c for c in input()])
T = sorted([c for c in input()], reverse=True)

for i in range(min(len(S), len(T))):
    if S[i] == T[i]:
        continue
    elif S[i] < T[i]:
        print('Yes')
        break
    else:
        print('No')
        break
else:
    if len(S) < len(T):
        print('Yes')
    else:
        print('No')

Solution (Python):
from sys import stdin


def main():
    s, t = [stdin.readline().rstrip() for _ in range(2)]
    s = ''.join(sorted(s))
    t = ''.join(sorted(t, reverse=True))
    print('Yes' if s < t else 'No')


if __name__ == "__main__":
    main()

Solution (Python):
s = sorted(str(input()))
t = sorted(str(input()), reverse=True)

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

Solution (Python):
print("YNeos"["".join(sorted(list(input())))>="".join(sorted(list(input()),reverse=True))::2])

Solution (Python):
s = input()
t = input()

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

if s_firstest < t_latest:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
s = list(input())
s.sort()
t = list(input())
t.sort(reverse = True)
for i in range(min(len(s),len(t))):
    if ord(s[i]) < ord(t[i]):
        print("Yes")
        sys.exit()
    elif ord(s[i]) > ord(t[i]):
        print("No")
        sys.exit()
print("Yes" if len(s) < len(t) else "No")

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

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

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

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

Solution (Python):
s=list(input())
t=list(input())
S=sorted(s)
T=sorted(t,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]):
    print('No')
    break
else:
  if len(S)<len(T):
    print('Yes')
  else:
    print('No')

Solution (Python):
s = list(input())
t = list(input())
s.sort()
t.sort(reverse = True)
flag_no = 0
i = 0
n = len(s)
m = len(t)
while True:
  if s[i] > t[i]:
    flag_no = 1
    break
  elif s[i] < t[i]:
    flag_no = 0
    break
  else:
    if i == n-1:
      if n < m:
        flag_no = 0
        break
      else:
        flag_no = 1
        break
    elif i == m-1:
      flag_no = 1
      break
  i += 1
if flag_no == 1:
  print("No")
else:
  print("Yes")

Solution (Python):
a = sorted(list(input()))
b = sorted(list(input()))[::-1]
l = sorted(["".join(a),"".join(b)])

if l[0] == "".join(a) and a != b:
  print("Yes")
else:
  print("No")

Solution (Python):
s = sorted(input())
t = sorted(input(), reverse=True)

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

Solution (Python):
s = input()
t = input()

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

Solution (Python):
s = str(input())
t = str(input())

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

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

Solution (Python):
s = list(str(input()))
t = list(str(input()))

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

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

Solution (Python):
s = input()
t = input()
s = list(s)
t = list(t)
s.sort()
t.sort()
t.reverse()
flag = False
for i in range(min(len(s),len(t))):
    if(s[i]<t[i]):
        flag = True
        break
    elif(s[i]>t[i]):
        flag = False
        break
    else:
        if(i == min(len(s),len(t))-1 and len(s)<len(t)):
            flag = True
if(flag):
    print('Yes')
else:
    print('No')

Solution (Python):
def main():
    if sorted(input()) < sorted(input(), reverse=True):
        print('Yes')
    else:
        print('No')


main()

Solution (Python):
def main():
    c = 'abcdefghijklmnopqrstuvwxyz'
    x = sorted(input())
    y = sorted(input(), reverse=True)
    if x == y[:len(x)] and len(y) > len(x):
        print('Yes')
    else:
        if c.index(x[0]) >= c.index(y[0]):
            print('No')
        else:
            print('Yes')


main()

Solution (Python):
s = input()
t = input()

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

Solution (Python):
def main():
  s = input()
  t = input()
  s2 = ''.join(sorted(s))
  t2 = ''.join(sorted(t)[::-1])
  if s2 < t2:
    print('Yes')
  else:
    print('No')


if __name__ == "__main__":
  main()

Solution (Python):
s=input()
t=input()
s_list=[s[i] for i in range(len(s))]
t_list=[t[j] for j in range(len(t))]
s_list.sort()
t_list.sort(reverse=True)
ss=""
for k in range(len(s_list)):
    ss+=s_list[k]
tt=""
for l in range(len(t_list)):
    tt+=t_list[l]
if ss<tt:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

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

    s = sorted(s)
    t = sorted(t)

    for i in s:
        for j in t:
            if ord(i)< ord(j):
                print('Yes')
                return


    if len(s)<len(t):
        ok = 1
        for i in s:
            if i not in t:
                ok = 0
        if ok:
            print('Yes')
            return


    print('No')

solve()

Solution (Python):
S = input()
T = input()

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

print(["Yes", "No"][not(s < t)])

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

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

Solution (Python):
s = sorted(str(input()))
t = sorted(str(input()))[::-1]
a = ["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"]
for i in range(min(len(s),len(t))):
    if t[i] > s[i]:
        print("Yes")
        break
    elif len(set(s)) == len(set(t)):
        if len(s) < len(t):
            print("Yes")
            break
else:
    print("No")

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

Solution (Python):

def read_input():
    s = input()
    t = input()
    return s, t



def greater_check(s, t):
    if len(s) < len(t):
        if s == t[:len(s)]:
            return True

    for i in range(min(len(s), len(t))):
        if s[i] < t[i]:
            return True

    return False

def submit():
    s, t = read_input()

    sc = [c for c in s]
    tc = [c for c in t]

    sc.sort()
    tc.sort(reverse=True)

    if greater_check(''.join(sc), ''.join(tc)):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    submit()

Solution (Python):
s = sorted(input())
t = sorted(input(), reverse=True)

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

Solution (Python):
s = sorted(input())
t = sorted(input())

if s[0] < t[-1]:
  print("Yes")
elif s[0] > t[-1]:
  print("No")
else:
  if s == t:
    print("No")
  elif "".join(s) in "".join(t):
    print("Yes")
  else:
    print("No")

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

Solution (Python):
S=input()
T=input()

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

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

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

Solution (Python):

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

Solution (Python):
s = sorted(input())
t = sorted(input(), reverse=True)

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

Solution (Python):
S = list(input())
T = list(input())

S.sort()
T.sort()
T = T[::-1]

S = "".join(S)
T = "".join(T)

print(['No', 'Yes'][(S < T)])

Solution (Python):
S = input()
T = input()

S = sorted(S)
T = sorted(T)[::-1]

print(['No', 'Yes'][(S < T)])

Solution (Python):

def main():
    S = input()
    T = input()

    s1 = [ord(s) - ord('a') for s in S]
    t1 = [ord(t) - ord('a') for t in T]

    s1.sort()
    t1.sort(reverse=True)


    for i, j in zip(s1, t1):
        if i < j:
            print('Yes')
            return

    if (len(s1) < len(t1)) & (i > j):
        print('No')
        return
    elif (len(s1) < len(t1)):
        print('Yes')
        return

    print('No')

main()

Solution (Python):
s = sorted(input())
t = sorted(input(), reverse=True)

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

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

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

Solution (Python):
import sys
from collections import Counter

s = input()
t = input()
s_list = []
t_list = []

for i in s:
    s_list.append(ord(i))

for i in t:
    t_list.append(ord(i))

s_list.sort()
t_list.sort(reverse=True)

for i in range(min(len(s_list), len(t_list))):
    if t_list[i] > s_list[i]:
        print('Yes')
        sys.exit()

if set(s_list) == set(t_list) and len(s_list) < len(t_list):
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
print('YNeos'[''.join(sorted(input()))>=''.join(sorted(input())[::-1])::2])

Solution (Python):
s = input()
t = input()

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

if s2 < t2:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

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

Solution (Python):
s = ''.join(sorted(list(input())))
t = ''.join(reversed(sorted(list(input()))))
S = sorted([s, t])
print('Yes' if s == S[0] and t != S[0] else 'No')

Solution (Python):
s = input()
t = input()
s = "".join(sorted(s))
t = "".join(sorted(t, reverse=True))


N = min(len(s), len(t))
f = False
for i in range(N):
  if s[i] < t[i]:
    print('Yes')
    f = True
    break
  elif s[i] > t[i]:
    print('No')
    f = True
    break
if not f:
  if len(s) < len(t):
    print('Yes')
  else:
    print('No')

Solution (Python):


import sys
import math


def srt(s, b):
  s = sorted(s)
  if b:
    s.reverse()
  ret = ""
  for c in s:
    ret += c
  return ret

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

s = srt(s,False)
t = srt(t,True)

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

Solution (Python):
s = input()
t = input()

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

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

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

Solution (Python):
s, t = [list(input()) for _ in range(2)]
s.sort()
t.sort(reverse=True)
if s < t:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    a = ''.join(sorted(input()))
    b = ''.join(sorted(input(), reverse=True))

    result = "Yes" if a < b else "No"
    print(result)




main()

Solution (Python):
print(["No","Yes"]["".join(map(str,sorted(input())))<"".join(map(str,sorted(input(),reverse=True)))])

Solution (Python):
s = input()
t = input()
s =sorted(s)
t = sorted(t, reverse=True)

bool = False

if s >= t:
    print('No')
else:
    print('Yes')

Solution (Python):
s,t=sorted(input()),sorted(input())
for i in range(min(len(s),len(t))):
    if ord(s[i])<ord(t[-i-1]):
        print("Yes")
        break
    elif ord(s[i])>ord(t[-i-1]):
        print("No")
        break
else:
    print("Yes" if len(s)<len(t) else "No")

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

Solution (Python):
alpha='abcdefghijklmnopqrstuvwxyz'
from collections import defaultdict
datas=defaultdict(int)
datat=defaultdict(int)
for s in input():
    datas[s]+=1
for t in input():
    datat[t]+=1
S=''
for k in alpha:
    S+=k*datas[k]
T=''
alpha=alpha[::-1]
for k in alpha:
    T+=k*datat[k]
alpha=alpha[::-1]
if len(S)<len(T) and S==T[:len(S)]:
    print('Yes')
elif S==T:
    print('No')
elif len(S)>len(T) and T==S[:len(T)]:
    print('No')
else:
    for i in range(min(len(S),len(T))):
        if alpha.index(S[i])<alpha.index(T[i]):
            print('Yes')
            break
        elif alpha.index(S[i])>alpha.index(T[i]):
            print('No')
            break

Solution (Python):
s = input()
t = input()

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

if s >= t:
    print('No')
else:
    print('Yes')

Solution (Python):
S=list(input())
S.sort()
T=list(input())
T.sort(reverse=True)

if ''.join(S)<''.join(T):
    print('Yes')
else:
    print('No')

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

Solution (Python):
s = [i for i in input()]
t = [i for i in input()]
s.sort()
t.sort(reverse=True)
s = ''.join(s)
t = ''.join(t)

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

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

Solution (Python):
import math

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

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

Solution (Python):
s=input()
t=input()
s_list=[]
t_list=[]
x=""
y=""
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)
for i in range(len(s)):
    x+=s_list[i]
for i in range(len(t)):
    y+=t_list[i]
if(x<y):
    print("Yes")
else:
    print("No")

Solution (Python):
s = sorted(input())
t = sorted(input(),reverse=True)

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

print('Yes') if ls < lt else print('No')

Solution (Python):
s = sorted(input())
t = sorted(input(),reverse=True)

ls = len(s)
lt = len(t)

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

Solution (Python):
s=list(str(input()))
t=list(str(input()))

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

print("YNeos"[s>=t::2])

Solution (Python):
s = input()
t = input()

s_list = []
for i in range(len(s)):
    s_list.append(s[i])
s_list.sort()
s = ""
for i in range(len(s_list)):
    s += s_list[i]

t_list = []
for i in range(len(t)):
    t_list.append(t[i])
t_list.sort()
t_list.reverse()
t = ""
for i in range(len(t_list)):
    t += t_list[i]

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

Solution (Python):
s = input()
t = input()

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

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

Solution (Python):
a=''.join(sorted(str(input())))
b=''.join(reversed(sorted(str(input()))))

if a<b:
    print("Yes")
else:
    print("No")

Solution (Python):
x = input()
y = input()  
 
xnew = sorted(x)
xnew = ''.join(xnew)
 
ynew = sorted(y)
ynew.reverse() 

ynew = ''.join(ynew)
 
if xnew < ynew:
  print("Yes")
else:
  print("No")

Solution (Python):

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

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

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

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

Solution (Python):
L = [str(input()) for i in range(2)]
A = sorted(L[0])
B = sorted(L[1])
if(A<B[::-1]):
    print("Yes")
else:
    print("No")

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

Solution (Python):
s = input()
t = input()


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

if s_sorted < t_sorted:
    print("Yes")
else:
    print("No")

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

Solution (Python):
S = list(input())
T = list(input())
S.sort(reverse=False)
T.sort(reverse=True)
S_sort = "".join(S)
T_sort = "".join(T)

if (S_sort < T_sort):
    print("Yes")
else:
    print("No")

Solution (Python):

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

Solution (Python):


def io_generator():
	return input()



def main(io):
	s=list(io())
	s.sort()
	t=list(io())
	t.sort(reverse = True)
	return 'Yes' if s < t else 'No'



if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Solution (Python):
s = sorted([i for i in input()])
t = sorted([i for i in input()],reverse =True)
if "".join(s)<"".join(t):
    print("Yes")
else:
    print("No")

Solution (Python):
s = list(str(raw_input()))
t = list(str(raw_input()))
s.sort()
t.sort(reverse=True)
s = ''.join(s)
t = ''.join(t)
if s < t:
	print 'Yes'
else:
	print 'No'

Solution (Python):
s = ''.join(sorted(list(input())))
t = ''.join(sorted(list(input()),reverse=True))


if  s != t and s == sorted([s,t])[0]:
 print("Yes")
else:
 print("No")

Solution (Python):
s = input()
t = input()

s_sorted = "".join(sorted(s))
t_sorted = "".join(sorted(t, reverse=True))

print('Yes' if s_sorted < t_sorted else 'No')

Solution (Python):
s = list(input())
t = list(input())

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

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

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

Solution (Python):
n=sorted(list(input()))
m=sorted(list(input()))
m=m[::-1]
if m>n:
  print("Yes")
else:
  print("No")

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

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

Solution (Python):
a = input()
b = input()

print("Yes" if sorted(a) < sorted(b)[::-1] else "No")

Solution (Python):

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

Solution (Python):
s = input()
t = input()

s = sorted(s)
t = sorted(t, reverse=True)
sl = "".join(s)
tl = "".join(t)

if sl < tl:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input().strip()
t = input().strip()

s = sorted(s)
t = sorted(t, reverse=True)
sl = "".join(s)
tl = "".join(t)

if sl < tl:
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
t=input()

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

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

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

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

Solution (Python):
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')

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

Solution (Python):
a=input()
m=[a[i] for i in range(len(a))]
b=input()
n=[b[i] for i in range(len(b))]
m.sort()
n.sort(reverse=1)
i=0
while 1>0:
  if i==len(b):
    print("No")
    break
  if i==len(a):
    print("Yes")
    break
  if m[i]<n[i]:
    print("Yes")
    break
  if m[i]>n[i]:
    print("No")
    break
  i+=1

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

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

Solution (Python):
s = input()
t = input()

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

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

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

Solution (Python):
S = sorted(input())
T = sorted(input(), reverse=True)

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

Solution (Python):
s = input().rstrip()
t = input()

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

Solution (Python):
s = list(input())
t = list(input())

ss = "".join(sorted(s))
tt = "".join(sorted(t, reverse=True))

if ss<tt:
    print("Yes")
else:
    print("No")

Solution (Python):
s = list(input().rstrip())
t = list(input().rstrip())
s.sort()
t.sort(reverse=True)

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

ans = "Yes" if s < t else "No"

print(ans)

Solution (Python):
s=list(input())
t=list(input())
n=len(s)
m=len(t)
s.sort()
t.sort(reverse=True)
ans='No'
for i in range(min(n,m)):
    if s[i]<t[i]:
        ans='Yes'
    elif s[min(n,m)-1]==t[min(n,m)-1] and n<m:
        ans='Yes'
print(ans)

Solution (Python):
s=list(input())
t=list(input())

s.sort()
t.sort()
t.reverse()

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