100 atcoder#ABC082B. [ABC082B] Two Anagrams

[ABC082B] Two Anagrams

Score : 200200 points

Problem Statement

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

Notes

For a string a=a1a2...aNa = a_1 a_2 ... a_N of length NN and a string b=b1b2...bMb = b_1 b_2 ... b_M of length MM, we say a<ba < b for the lexicographic order if either one of the following two conditions holds true:

  • N<MN < M and a1=b1a_1 = b_1, a2=b2a_2 = b_2, ..., aN=bNa_N = b_N.
  • There exists ii (1iN,M1 \leq i \leq N, M) such that a1=b1a_1 = b_1, a2=b2a_2 = b_2, ..., ai1=bi1a_{i - 1} = b_{i - 1} and ai<bia_i < b_i. Here, letters are compared using alphabetical order.

For example, xy << xya and atcoder << atlas.

Constraints

  • The lengths of ss and tt are between 11 and 100100 (inclusive).
  • ss and tt consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

ss

tt

Output

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

yx
axy
Yes

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

ratcode
atlas
Yes

We can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort << tslaa.

cd
abc
No

No matter how we rearrange cd and abc, we cannot achieve our objective.

w
ww
Yes
zzz
zzz
No