#P13491. 【MX-X14-T1】拼凑基因

【MX-X14-T1】拼凑基因

Description

Little A gives you two strings SS and TT, each of length nn. He wants to know whether SS can be partitioned into several substrings* and then concatenated in any order to form TT.

*A substring is defined as a contiguous segment of characters from the original string.

Input Format

The first line contains an integer nn.

The second line contains a string SS of length nn.

The third line contains a string TT of length nn.

It is guaranteed that SS and TT consist only of lowercase English letters.

Output Format

Output a single line with the string Yes or No, indicating whether SS can be transformed into TT by partitioning it into substrings and concatenating them in any order.

5
xyzab
abxyz
Yes
6
aabbcc
bccaab
Yes
3
abc
bda
No

Hint

【Sample Explanation #1】

SS can be partitioned into two substrings, xyz\texttt{xyz} and ab\texttt{ab}, and then concatenated in reverse order to form abxyz\texttt{abxyz}.

【Sample Explanation #2】

SS can be partitioned into aa\texttt{aa}, b\texttt{b}, and bcc\texttt{bcc}, and then concatenated to form bccaab\texttt{bccaab}.

【Sample Explanation #3】

It can be proven that no matter how SS is partitioned and concatenated, it cannot be transformed into TT.

【Data Range】

For 10%10\% of the data, n10n \le 10.

For 30%30\% of the data, n20n \le 20.

For 60%60\% of the data, n103n \le 10^3.

For 100%100\% of the data, 1n1051 \le n \le 10^5, and it is guaranteed that SS and TT consist only of lowercase English letters.


Translated by DeepSeek V3.