AT_past202303_e 図形のシャッフル

Description

You are given figures $ S $ and $ T $ with $ H $ rows and $ W $ columns consisting of `#` and `.`. The figure $ S $ is given as $ H $ strings $ S _ 1,S _ 2,\ldots,S _ H $ ; the $ j $ -th character of $ S _ i $ represents the element at the $ i $ -th row and $ j $ -th column of $ S $ . The figure $ T $ is given similarly. Determine whether one can rearrange each row of $ S $ to make $ S $ equal $ T $ . Here, rearranging each row of a figure $ X $ is the following operation. - For each $ i=1,2,\ldots,H $ , perform the following procedure independently. - Choose a permutation $ P=(P _ 1,P _ 2,\ldots,P _ W) $ of $ (1,2,\ldots,W) $ . - For all integers $ j $ such that $ 1 \leq j \leq W $ , simultaneously replace the element at the $ i $ -th row and $ j $ -th column of $ X $ with the one at the $ i $ -th row and $ P_j $ -th column. Note that you may choose different permutations $ P $ for different $ i $ .

Input Format

The input is given from Standard Input in the following format: > $ H $ $ W $ $ S_1 $ $ S_2 $ $ \vdots $ $ S_H $ $ T_1 $ $ T_2 $ $ \vdots $ $ T_H $

Output Format

Print `Yes` if one can make $ S $ equal $ T $ ; print `No` otherwise.

Explanation/Hint

### Sample Explanation 1 For example, if you choose $ (4,2,1,3),(1,3,4,2),(4,1,3,2) $ for $ i=1,2,3 $ , respectively, you can make $ S $ equal $ T $ . ### Sample Explanation 3 $ S=T $ may hold. ### Constraints - $ H $ and $ W $ are integers. - $ 1 \leq H,W $ - $ 1 \leq H \times W \leq 4 \times 10 ^ 5 $ - $ S_i $ and $ T_i $ are strings of length $ W $ consisting of `#` and `.`.