AT_past202303_j 図形のシフト

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 it is possible to shift the columns of $ S $ so that $ S $ will equal $ T $ . Here, shifting the columns of $ S $ is the following operation. - Choose an integer $ s $ between $ 1 $ and $ W $ , inclusive. - Then, for every integer $ i $ such that $ 1 \leq i \leq H $ , simultaneously perform the following: - for every integer $ j $ such that $ 1 \leq j \leq W $ , simultaneously replace the element at the $ i $ -th row and $ j $ -th column with that of the $ i $ -th row and $ (j+s) $ -th column of $ X $ . Here, for $ x $ such that $ W \gt x $ , the $ x $ -th column means the $ y $ -th column where $ y\ (1\leq y\leq W) $ is the only integer such that $ x-y $ is a multiple of $ W $ .

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

If it is possible to make $ S $ equal $ T $ , print `Yes`; otherwise, print `No`.

Explanation/Hint

### Sample Explanation 1 Choosing $ s=2 $ will make $ S $ equal $ T $ . ### Sample Explanation 2 You can only shift the columns and not turn over the figure. ### Sample Explanation 3 It may be the case that $ S=T $ . ### Constraints - $ H $ and $ W $ are integers. - $ 1 \le H,W $ - $ 1 \le H \times W \le 4 \times 10^5 $ - $ S_i $ and $ T_i $ are strings of length $ W $ consisting of `#` and `.`.